Skip to content

Instantly share code, notes, and snippets.

@thomasfr
Last active December 1, 2019 20:04
Show Gist options
  • Save thomasfr/8653547 to your computer and use it in GitHub Desktop.
Save thomasfr/8653547 to your computer and use it in GitHub Desktop.
nginx vhost / site config file
upstream node_backend {
server 127.0.0.1:3000;
keepalive 32;
}
server {
root /var/www/testapp/public;
index index.html;
server_name example.com localhost;
location / {
#auth_basic "Restriced";
#auth_basic_user_file /etc/nginx/htpasswd;
try_files $uri @backend;
## or
#try_files $uri $uri/ @backend;
}
location @backend {
## If you use express, make sure you set "trust proxy" to true
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto http;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
## Make sure you know what this means. Default nginx setting for proxy_buffering is 'on'
proxy_buffering off;
## Keep the connection open / alive
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://node_backend;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment