0
votes

I have a Wicket application that is using WebSockets and is running in Jetty on port 9090. What I want to do is to use NGINX as a proxy, so users can access the application using standard 80 port.

Using instructions found in this thread:

How do I configure nginx as proxy to jetty?

I have added following entries to /etc/nginx/sites-available/default:

location /myapp {
    proxy_pass       http://localhost:9090/myapp;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
}

But now when I open the application through 80 port I can see an error in Chrome console:

WebSocket connection to 'ws://xxx.xxx.xxx.xxx/myapp/wicket/websocket?pageId=2&wicket-ajax-baseurl=whatmovie%3F2&wicket-app-name=myapp' failed: Error during WebSocket handshake: Unexpected response code: 404

WebSockets no longer work. So I've been googling around and found this thread:

NGINX to reverse proxy websockets AND enable SSL (wss://)?

So I have added folowing entries to NGINX config:

location /myapp/wicket/websocket {
    proxy_pass http://localhost:9090/myapp/wicket/websocket;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

After that when I access the application there is no longer any error in console, and I can see in the logs that websockets are created. Unfortunately the comunication between client and the application doesn't seem to work anymore. Can anyone help me with that?

Details of my configuration:

  • Debian 7.8
  • jetty-9.0.6.v20130930
  • Wicket 7.0.0 with wicket-native-websocket-jetty9
1

1 Answers

0
votes

Turned out that upgrading nginx to version 1.8.0-1 solved the issue. Thats the content of my /etc/nginx/conf.d/default.conf:

server {
    listen       80;
    server_name  localhost;

    location /app {
        proxy_pass             http://localhost:9090/app;
        proxy_set_header       Host $host;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

}