Created
March 3, 2014 00:56
-
-
Save BenHall/9316648 to your computer and use it in GitHub Desktop.
nginx config file
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
upstream domain { | |
server 127.0.0.1:3001; | |
} | |
server { | |
listen 80; | |
server_name domain.io another.domain.io; | |
return 301 http://main.domain.com$request_uri; | |
} | |
server { | |
listen 80; | |
server_name main.domain.com; | |
access_log /var/log/nginx/domain-com.log; | |
location ~ ^/(images|javascript|javascripts|stylesheets|fonts|robot.txt)/ { | |
root /var/www/domain/public; | |
expires 1d; | |
} | |
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://domain; | |
proxy_redirect off; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Forces redirect to main.domain.com, for example entering non-www URL or an alternative ending.
Static files are served directly from the directory the node app lives in. Other requests are sent to port 3001 running on the same box.