Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/etc/nginx/common/nginx.conf basic NGINX location rules common to all website platforms. Should be included in all virtual site configurations.
#---------------------------------------------------------------------------
# @(#)$Id$
#title :/etc/nginx/common/nginx.conf
#description :ftmon cluster nginx common config for all sites.
#author :Danny W Sheehan
#date :July 2014
#website :ftmon.org
#
# This is a work in progress. A lot of trial and error and man hours have
# gone into this configuration. I have referenced sources that have been
# helpful.
#
# ftmon cluster is tuned for KVM with 1G of memory and 1 cpu.
#
# Final configuration will be available at https://github.com/ftmon as
# opensource.
#---------------------------------------------------------------------------
# Basic rules common to all website platforms - Wordpress, forums etc.
# show "not found" errors rather than forbidden errors to confuse potential
# threats by hiding our privite bits.
error_page 403 =404;
# support for favicon. Return 1x1 transparent GIF
# my little trick for having multiple favicons for multisites.
location ~* favicon.ico$ {
pagespeed off;
access_log off;
log_not_found off;
expires max;
try_files /images/$host.ico /images/$host.png $uri /favicon.ico /favicon.png / @empty;
}
# return empty 1x1 transparent GIF
location @empty {
access_log off;
pagespeed off;
log_not_found off;
expires max;
empty_gif;
}
# don't log every time this file is accessed.
location = /robots.txt {
access_log off;
pagespeed off;
log_not_found off;
try_files /robots.txt @robots;
}
# sick of creating robot files? - use this.
location @robots {
add_header Content-Type text/plain;
return 200 "User-agent: *\nAllow: /\n";
}
# Add annoying image names that people forget to include in their
# plugins, themes.
location ~* (accept.png|missing-image.png)$ {
pagespeed off;
access_log off;
log_not_found off;
expires max;
try_files $uri @empty;
}
# Ask browser to cache Static Files for as long as possible.
# bypass any backend processing by letting nginx service them if they exit.
location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|webp)$ {
try_files $uri =404;
access_log off;
log_not_found off;
expires max;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.