Skip to content

Instantly share code, notes, and snippets.

@riyadhalnur
Last active December 20, 2015 10:23
Show Gist options
  • Save riyadhalnur/61f9564064c4d3333273 to your computer and use it in GitHub Desktop.
Save riyadhalnur/61f9564064c4d3333273 to your computer and use it in GitHub Desktop.
Server config for hosting NodeJS apps behind a NGINX reverse proxy server
server {
listen 443;
server_name mydomain.com www.mydomain.com;
access_log /var/logs/access.log main_timed;
# See https://mozilla.github.io/server-side-tls/ssl-config-generator/ for appropriate SSL settings
ssl on;
ssl_certificate /opt/ssl/site/mydomain.com.crt;
ssl_certificate_key /opt/ssl/site/mydomain.com.key;
add_header Strict-Transport-Security max-age=15768000;
location / {
proxy_pass http://localhost:3000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 180;
proxy_connect_timeout 10s;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_redirect http:// https://;
proxy_next_upstream error timeout invalid_header http_502 http_503 http_504;
add_header X-Cached $upstream_cache_status;
proxy_cache_use_stale off;
proxy_cache liferay_cache;
gzip_comp_level 3;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment