Skip to content

Instantly share code, notes, and snippets.

@wernersmit
Last active July 18, 2016 10:09
Show Gist options
  • Save wernersmit/9d88fa9eb62b0cd0b38839856b5ccf05 to your computer and use it in GitHub Desktop.
Save wernersmit/9d88fa9eb62b0cd0b38839856b5ccf05 to your computer and use it in GitHub Desktop.
Nginx Site Declaration
server {
listen 80;
server_name fqdn.domain.com;
access_log /var/log/nginx/fqdn.domain.com-access.log;
gzip on;
gzip_static on;
gzip_http_version 1.1;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
gzip_vary on;
# cache.appcache, your document html and data
#location ~* \.(?:manifest|appcache|html?|xml|json)$ {
# expires -1;
#}
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1h;
access_log off;
proxy_cache my_zone;
proxy_cache_valid 200 60m;
include /etc/nginx/proxy_params;
}
# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 1h;
access_log off;
proxy_cache my_zone;
proxy_cache_valid 200 60m;
add_header Cache-Control "public";
include /etc/nginx/proxy_params;
}
# PDFs
location ~* \.(?:pdf)$ {
expires -1;
access_log off;
proxy_cache my_zone;
proxy_cache_valid 200 60m;
add_header Cache-Control "public";
include /etc/nginx/proxy_params;
}
# WebFonts
# If you are NOT using cross-domain-fonts.conf, uncomment the following directive
location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ {
expires 1M;
proxy_cache my_zone;
proxy_cache_valid 200 60m;
access_log off;
add_header Cache-Control "public";
include /etc/nginx/proxy_params;
}
# Catch all - processes request not handled.
location / {
proxy_hide_header X-Pingback;
include /etc/nginx/proxy_params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment