Created
June 28, 2013 05:57
-
-
Save justinwinslow/5882743 to your computer and use it in GitHub Desktop.
Baseline node.js nginx configuration
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
# Add multiple servers at different ports for load balancing | |
upstream node { | |
server 127.0.0.1:3005; | |
} | |
# the nginx server instance | |
server { | |
listen 0.0.0.0:80; | |
server_name {{ your_app_name }} {{ your.domain.com }}; | |
access_log /var/log/nginx/{{ your.domain.com }}.log; | |
root /path/to/app; | |
# Long expiration on favicon | |
location ~* ^.+\.ico$ { | |
access_log off; | |
expires 30d; | |
} | |
# Moderate expiration for static assets | |
location ~* ^.+\.(jpg|jpeg|gif|png|css|js|mp3)$ { | |
access_log off; | |
expires 3d; | |
} | |
try_files $uri @node; | |
location @node { | |
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_redirect off; | |
proxy_pass http://node; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment