If you want to reverse proxy the websocket for a domain to a URL in nginx on Ubuntu then you need to add the following section in the configuration file of your site:
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
Go to your /etc/nginx/sites-available/<yourdomain> file and add the above section there at the location where you want to redirect. The complete file will look like this:
server {
server_name yourdomain.com;
location / {
proxy_pass https://127.0.0.1:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}