Last active
January 9, 2018 22:02
-
-
Save skoch/6dca3a0771bcec48fd9f3291bc0cdd42 to your computer and use it in GitHub Desktop.
nginx setup with browser caching and redirect to www
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
# see: https://www.digitalocean.com/community/tutorials/how-to-implement-browser-caching-with-nginx-s-header-module-on-centos-7 | |
# Expires map | |
map $sent_http_content_type $expires { | |
default off; | |
text/html epoch; | |
text/css max; | |
application/javascript max; | |
~image/ max; | |
} | |
server { | |
listen 80; | |
server_name domain.com; | |
rewrite ^(.*) http://www.domain.com$1 permanent; | |
} | |
server { | |
server_name www.domain.com; | |
location / { | |
proxy_pass http://localhost:9999; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_cache_bypass $http_upgrade; | |
} | |
expires $expires; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment