# Designed to be included in any server {} block.
# GLOBAL RESTRICTIONS
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Block access to "hidden" files and directories whose names begin with a
# period. This includes directories used by version control systems such
# as Git to store control files.
location ~ (^|/). {
return 403;
}
# Directives to send expires headers and turn off 404 error logging.
location ~* .(jpg|jpeg|png|gif|css|js|ico)$ {
log_not_found off;
expires max;
}
# Very rarely should these ever be accessed outside of your lan.
location ~* .(txt|log)$ {
allow 192.168.0.0/16;
deny all;
}
# E107 SINGLE SITE RULES
# Charset.
charset utf-8;
# Custom error pages for php scripts only.
error_page 500 /error.php?500;
error_page 404 /error.php?404;
error_page 403 /error.php?403;
# Send 404 on missing files in these folders.
location ~ /(e107_images|e107_files)/ {
}
# Block Bad Bots.
# deny env=http_safe_badbot;
# Disable directory listing.
autoindex off;
# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
try_files $uri $uri/ /index.php?$args;
}
location / {
# Allow only GET and POST methods.
if ($request_method ~ "^(TRACE|TRACK|OPTIONS|HEAD)"){
return 403;
}
# Single entry point.
# Don't rewrite for existing files, directories and links.
if (!-e $request_filename){
rewrite ^(.*)$ /index.php last;
}
}
# Secure htaccess file.
location /.htaccess {
deny all;
}
# Protect e107_config.php.
location /e107_config.php {
deny all;
}
# Deny access to any files with a .php extension in the uploads directory.
location ~* /(?:e107_media)/.*.php$ {
deny all;
}
# Add trailing slash to */e107_admin requests.
rewrite /e107_admin$ $scheme://$host$uri/ permanent;
# CACHE RULES
# Directives to send expires headers and turn off 404 error logging.
location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp3|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off;
log_not_found off;
expires max;
}
location ~* /(?:e107_web)/js/e_jslib.php(.*)$ {
expires max;
}
location ~* /thumb.php(.*)$ {
expires max;
}