Here’s a simple configuration to allow nginx to proxy through to another process including forwarding websocket traffic.
A simple set up currently in use to proxy to a nodejs process which is also serving HTML. I’d like to improve the config so that nginx serves static content, but will look to do that later.
Improvements, suggestions please add to the comments (…and thanks).
server { listen 80; server_name example.com; return 301 https://example.com$request_uri; } server { listen 443; server_name example.com; root /var/www/html/public; ssl on; ssl_certificate /etc/ssl/private/ssl.cert; ssl_certificate_key /etc/ssl/private/ssl.key; ssl_protocols SSLv2 SSLv3 TLSv1; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; proxy_connect_timeout 43200000; proxy_read_timeout 43200000; proxy_send_timeout 43200000; if ($ssl_protocol = "") { rewrite ^ https://$host$request_uri? permanent; } try_files $uri @proxysocket; location / { proxy_pass http://127.0.0.1:3000/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }