Created
January 25, 2013 08:26
-
-
Save ndrut/4632758 to your computer and use it in GitHub Desktop.
My basic nginx configuration for a node.js express application.
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 api { | |
server 127.0.0.1:3000; | |
keepalive 10; | |
} | |
server { | |
listen 80; | |
server_name yourdomain.com www.yourdomain.com; | |
# | |
# You can ignore the majority of these next lines, | |
# they're for if your app will be behing cloudflare. | |
# | |
# set_real_ip_from 204.93.240.0/24; | |
# set_real_ip_from 204.93.177.0/24; | |
# set_real_ip_from 199.27.128.0/21; | |
# set_real_ip_from 173.245.48.0/20; | |
# set_real_ip_from 103.22.200.0/22; | |
# set_real_ip_from 141.101.64.0/18; | |
# set_real_ip_from 108.162.192.0/18; | |
# set_real_ip_from 190.93.240.0/20; | |
# set_real_ip_from 2400:cb00::/32; | |
# set_real_ip_from 2606:4700::/32; | |
# set_real_ip_from 2803:f800::/32; | |
# real_ip_header CF-Connecting-IP; | |
# proxy_set_header X-Real-IP $remote_addr; | |
# proxy_set_header Host $host; | |
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
location / { | |
# Proxy all requests to your API. | |
proxy_pass http://api; | |
} | |
location ~* /.+\.(jpg|png|gif|jpeg|css|js|mp3|wav|swf|mov|ico)$ { | |
# Document root for the static files. | |
root /home/api/public; | |
expires 864000; | |
} | |
location = /50x.html { | |
# When your app is unreachable, this file will be used | |
root /var/www/nginx-default; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @ndrut it works well for my use case