Reverse-proxy/rewrite for Perspective with Nginx, stuck on "Authenticating..."

I apologize if this is outside of the scope of this forum, but here goes.

The relevant bit of my nginx.conf is:

rewrite /dashboard /data/perspective/client/DashboardProject last;

location / {
    proxy_pass http://site.com:8088;
}

This is within the http, server block, and the server is listening on port 80.

I’ve changed the Web Server settings to look like:

Otherwise everything is default.

This seems to redirect properly, Perspective starts to load, but I get this and it stays stuck there.

Is there something I’m missing in my configuration?

Here’s some more information I was able to glean from the Chrome console. I’m getting this error:

WebSocket connection to 'ws://site.com/system/pws/DashboardProject/222da13b' failed: Error during WebSocket handshake: Unexpected response code: 400

The access log for nginx is showing:

 "GET /system/pws/DashboardProject/222da13b HTTP/1.1" 400 499 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"

I’m not seeing any gateway logs with any errors related to this.

It seems like my issue is with Nginx in this case? Or something with the interaction between proxying from Nginx to Ignition’s internal server.

I’ve been trying various other permutations of this configuration, including:

location /  {
    proxy_pass http://site.com:8088;
    rewrite ^/dashboard$ /data/perspective/client/DashboardProject last;
}	
location / {
    proxy_pass http://site.com:8088;
}

location = /dashboard {
    proxy_pass http://site.com:8088/data/perspective/client/DashboardProject;
}

All with the same results. Something with the ws:// request is failing and I can’t seem to find out why it’s not being passed through to Ignition.

Looks like you might need additional rules in the proxy config to correctly pass the websocket upgrade messages?
http://nginx.org/en/docs/http/websocket.html

2 Likes

Okay! That seemed to fix it! Thank you so much for the help.

I’ve decided to change my plan a bit from rewriting to just permanent redirecting, so here’s the final relevant section of my nginx config if anyone else runs into this:

location /  {
    proxy_pass http://site.com:8088;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    rewrite ^/dashboards$ /data/perspective/client/DashboardProject permanent;
}	
6 Likes

Glad you figured it out.

We ran into the same thing using IIS rwp / url rewrite. It was fixed by adding the HTTP_SEC_WEBSOCKET_EXTENSIONS to ‘Server Variables’ in the xml file. Just replying incase it’s useful in the future.

3 Likes

Hi sorry to comment on an old post,

I noticed that it looks like you are redirecting with this line
rewrite ^/dashboards$ /data/perspective/client/DashboardProject permanent;
so that the url is effectively shorter

If that is right, did that work out for you? I tried to do this and eventually gave up because it was giving me problems.