Skip to content

Instantly share code, notes, and snippets.

@scvnc
Last active January 3, 2016 19:59
Show Gist options
  • Save scvnc/8511605 to your computer and use it in GitHub Desktop.
Save scvnc/8511605 to your computer and use it in GitHub Desktop.
This tells nginx to forward requests to an express application listening on 127.0.0.1:9005 when the requested hostname matches pub.webjcl.* This one rests in /etc/nginx/sites-available and is symlinked from /etc/nginx/sites-enabled.
# Define a server label which points to where we have node.js listening
upstream pub-webjcl {
server 127.0.0.1:9005;
}
server {
# Make site accessible from http://pub.webjcl.*
server_name pub.webjcl.*;
# Proxy to pub-webjcl
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_pass http://pub-webjcl;
proxy_redirect off;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment