Skip to content

Instantly share code, notes, and snippets.

@crookm
Created February 7, 2018 03:54
Show Gist options
  • Save crookm/b0d959a9ab69e8559745b88152929783 to your computer and use it in GitHub Desktop.
Save crookm/b0d959a9ab69e8559745b88152929783 to your computer and use it in GitHub Desktop.
NGINX config file for node.js applications with websocket support and ssl
server {
listen 80;
server_name example.com www.example.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:<PROJECT PORT>;
proxy_redirect off;
# socket.io support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
server {
listen 443 ssl;
server_name example.com www.example.com;
# ssl certs and keys
ssl_certificate /etc/ssl/certs/<YOUR CERTIFICATE>.crt;
ssl_certificate_key /etc/ssl/private/<YOUR SECRET KEY>.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'AES128+EECDH:AES128+EDH';
ssl_prefer_server_ciphers on;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:<PROJECT PORT>;
proxy_redirect off;
# socket.io support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment