Created
April 27, 2018 10:16
-
-
Save swarajgiri/b3ebf91d241b463b879605ca12bdf40a to your computer and use it in GitHub Desktop.
nginx conf
This file contains hidden or 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 app { | |
server 127.0.0.1:3000; | |
} | |
server { | |
listen 80; | |
server_name site.com www.site.com; | |
return 301 https://site.com$request_uri; | |
} | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name site.com; | |
add_header Strict-Transport-Security "max-age=31536000"; | |
# Optimise internal TCP connections | |
tcp_nopush on; | |
tcp_nodelay on; | |
error_log /var/log/nginx/app-error.log error; | |
access_log /var/log/nginx/app.log; | |
location ~ ^/(flash/|media/|static/|robots.txt|humans.txt) { | |
root /path/to/web/app; | |
access_log off; | |
expires max; | |
sendfile on; | |
sendfile_max_chunk 1m; | |
add_header Pragma public; | |
add_header Cache-Control "public, must-revalidate, proxy-revalidate"; | |
} | |
location ~ ^/(assets/|images/|img/|javascript/|js/|css/|stylesheets/|favicon.ico) { | |
root /path/to/web/app/; | |
access_log off; | |
expires max; | |
sendfile on; | |
sendfile_max_chunk 1m; | |
add_header Pragma public; | |
add_header Cache-Control "public, must-revalidate, proxy-revalidate"; | |
} | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-NginX-Proxy true; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_pass http://app/; | |
proxy_redirect off; | |
} | |
location /nginx_status { | |
stub_status on; | |
# I do not need logs for stats | |
access_log off; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment