Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.