Skip to content

Instantly share code, notes, and snippets.

@ile
Created November 17, 2014 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ile/c1b77811b27311467096 to your computer and use it in GitHub Desktop.
Save ile/c1b77811b27311467096 to your computer and use it in GitHub Desktop.
upstream nodejs {
server 127.0.0.1:3000;
keepalive 8;
}
server {
listen 80;
listen [::]:80 ipv6only=on default_server;
server_name mydomain.fi;
return 301 https://$server_name$request_uri;
}
# the nginx server instance
server {
listen 443 default_server ssl;
server_name mydomain.fi;
access_log /var/log/nginx/mydomain.log;
ssl_certificate /data/myapp/data/keys/bundle.crt;
ssl_certificate_key /data/myapp/data/keys/ssl.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers RC4:HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SS:10m;
ssl_session_timeout 10m;
keepalive_timeout 60;
# root /data/myapp;
location ~ ^/(profile/|derby/|images/|img/|javascript/|js/|css/|stylesheets/|flash/|media/|static/|robots.txt|humans.txt|favicon.png|favicon2.png) {
root /data/myapp/public;
access_log off;
expires max;
}
# pass the request to the node.js server with the correct headers and much more can be added, see nginx config options
location / {
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;
proxy_set_header X-NginX-Proxy true;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://nodejs;
proxy_redirect off;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment