Created
April 25, 2015 02:26
-
-
Save mechastorm/2565351fe8e09a9c41ac to your computer and use it in GitHub Desktop.
nginx_view_stage
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
server { | |
set $rootPath /var/www/vhosts/mysite/public; | |
listen 80; | |
server_name assets.mydomain.com; | |
root $rootPath; | |
access_log /var/log/nginx/access_assets.log; | |
error_log /var/log/nginx/error_assets.log debug; | |
index index.html index.htm; | |
# Any files matching these extensions are cached for a long time | |
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { | |
expires max; | |
add_header Cache-Control public; | |
} | |
# Don't throw any errors for missing favicons and don't display them in the logs | |
location /favicon.ico { | |
log_not_found off; | |
access_log off; | |
error_log off; | |
} | |
# Deny these extensions | |
location ~* \.(txt|php|less)$ { | |
deny all; | |
} | |
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). | |
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) | |
location ~ /\. { | |
deny all; | |
} | |
location ~* ^/v(.*)/ { | |
alias $rootPath; | |
} | |
location / { | |
try_files $uri $uri/; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment