Skip to content

Instantly share code, notes, and snippets.

@sagivo
Created November 14, 2013 20:13
Show Gist options
  • Save sagivo/7473564 to your computer and use it in GitHub Desktop.
Save sagivo/7473564 to your computer and use it in GitHub Desktop.
node.js api with static homepage for nginx users that visit you site via html will go to static html files. users who use api calls (yoursite.com/v1/ ) will redirect to the node app
server {
listen 0.0.0.0:80;
listen [::]:80 default_server ipv6only=on;
server_name localhost;
access_log /var/log/nginx/app.log;
root /usr/share/nginx/html/app-static;
index index.html;
location /v1 {
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_pass http://node;
}
}
upstream node {
server 127.0.0.1:3000;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment