Nginx config for proxying a nodejs app

I prefer to host my nodejs applications behind an nginx proxy. After several revisions this has become my favorite configuration to use.

This includes support for websockets.

server {  
  listen 80;
  server_name [your.domain.com];
  return 301 https://$server_name$request_uri;
}

server {  
  listen 443;
  server_name [your.domain.com];

  error_log /var/log/nginx/error.log;

  client_max_body_size 20m;

  ssl on;
  ssl_certificate [your ssl cert];
  ssl_certificate_key [your private key];

  location / {
    proxy_pass http://[yournodeserver];
    proxy_http_version 1.1;

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;                                                   
    proxy_set_header X-Forwarded-Proto $scheme;                                                                      
    proxy_set_header X-Nginx-Proxy true;

    proxy_redirect off;
    proxy_connect_timeout 60s;
    proxy_send_timeout 600s;
    proxy_read_timeout 600s;
  }
}