Created
November 14, 2013 20:13
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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