ifblacklist.conf
## Deny access based on the User-Agent header. if ($bad_bot) { return 444; } ## Deny access based on the Referer header. if ($bad_referer) { return 444; }
drop.conf
## All files/directories that are protected and unaccessible from ## the web. location ~* ^.*(\.(?:git|svn|htaccess|pot?))$ { return 404; } location ~ ~$ { access_log off; log_not_found off; deny all; }
wordpress_w3_cache.conf
#rewrite_log on; if (!-e $request_filename) { rewrite /wp-admin$ $scheme://$host$uri/ permanent; rewrite ^(/[^/]+)?(/wp-.*) $2 last; rewrite ^(/[^/]+)?(/.*\.php) $2 last; } set $cache_uri $request_uri; # POST requests and urls with a query string should always go to PHP if ($request_method = POST) { set $cache_uri 'NULL'; } if ($query_string != "") { set $cache_uri 'NULL'; } # Don't cache uris containing the following segments if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { set $cache_uri 'NULL'; } # Don't use the cache for logged in users or recent commenters if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") { set $cache_uri 'NULL'; } # Use cached or actual file if they exists, otherwise pass request to WordPress location / { try_files /wp-content/cache/page_enhanced/${host}${cache_uri}_index.html $uri $uri/ /index.php?$args ; } location ~ ^/wp-content/cache/minify/[^/]+/(.*)$ { try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1; }
static.conf
## Static files are served directly. location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf|woff)$ { expires max; log_not_found off; ## No need to bleed constant updates. Send the all shebang in one ## fell swoop. tcp_nodelay off; ## Set the OS file cache. open_file_cache max=1000 inactive=5m; open_file_cache_valid 2m; open_file_cache_min_uses 2; open_file_cache_errors off; } ## Pseudo streaming for FLVs. ## http://wiki.nginx.org/HttpFlvStreamModule. location ~* \.flv$ { flv; } ## Pseudo streaming of H264/AAC files. This requires an Nginx ## version greater or equal to 1.0.7 for the stable branch and ## greater or equal to 1.1.3 for the development branch. ## Cf. http://nginx.org/en/docs/http/ngx_http_mp4_module.html. location ~* .*\.(?:m4a|mp4|mov)$ { mp4; mp4_buffer_size 1M; mp4_max_buffer_size 5M; } ## Keep a tab on the 'big' static files. location ~* ^.+\.(?:ogg|pdf|pptx?)$ { expires 30d; ## No need to bleed constant updates. Send the all shebang in one ## fell swoop. tcp_nodelay off; }
wordpress-sitemap.conf
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last; rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last; rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last; rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
wordpress_fastcgi_cache.conf
set $skip_cache 0; # POST requests and urls with a query string should always go to PHP if ($request_method = POST) { set $skip_cache 1; } if ($query_string != "") { set $skip_cache 1; } # Don't cache uris containing the following segments # datum.php och opcache.php for test remove if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") { set $skip_cache 1; } # Don't use the cache for logged in users or recent commenters # webway_adelsvapen_ad_UserID for wiki on adelsvapen *_ad_UserID if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { set $skip_cache 1; } location / { try_files $uri $uri/ /index.php?$args; }
Tar bort cache kan man göra genom att :
./tabortcache http://www.demo.se/time.php
filen tabortcache
#!/usr/bin/env bash echo "Before purging:" exec 6<>/dev/tcp/127.0.0.1/80 echo -ne "GET $1 HTTP/1.0\r\n\r\n" >&6 while read -r -u 6 do if [[ ${REPLY} =~ ^$ ]]; then break elif [[ ${REPLY} =~ ^(Last-Modified|X-Cached):(.*)$ ]]; then case ${BASH_REMATCH[1]} in Last-Modified) echo -ne "\tFile date:\t\t${BASH_REMATCH[2]}\n" ;; X-Cached) echo -ne "\tStatus:\t\t${BASH_REMATCH[2]}\n" ;; esac fi done exec 6>&- echo "Purging file." exec 6<>/dev/tcp/127.0.0.1/80 echo -ne "GET $1 HTTP/1.0\r\nCache-Purge: 1\r\n\r\n" >&6 while read -r -u 6 do if [[ ${REPLY} =~ ^$ ]]; then break elif [[ ${REPLY} =~ ^(Last-Modified|X-Cached):(.*)$ ]]; then case ${BASH_REMATCH[1]} in Last-Modified) echo -ne "\tFile date:\t\t${BASH_REMATCH[2]}\n" ;; X-Cached) echo -ne "\tStatus:\t\t${BASH_REMATCH[2]}\n" ;; esac fi done exec 6>&- echo "After purging:" exec 6<>/dev/tcp/127.0.0.1/80 echo -ne "GET $1 HTTP/1.0\r\n\r\n" >&6 while read -r -u 6 do if [[ ${REPLY} =~ ^$ ]]; then break elif [[ ${REPLY} =~ ^(Last-Modified|X-Cached):(.*)$ ]]; then case ${BASH_REMATCH[1]} in Last-Modified) echo -ne "\tFile date:\t\t${BASH_REMATCH[2]}\n" ;; X-Cached) echo -ne "\tStatus:\t\t${BASH_REMATCH[2]}\n" ;; esac fi done exec 6>&-
fastcgi_conf
#-*- mode: nginx; mode: flyspell-prog; mode: autopair; ispell-local-dictionary: "american" -*- ### fastcgi configuration. try_files $uri =404; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; #fastcgi_buffers 256 4k; fastcgi_intercept_errors on; ## allow 4 hrs - pass timeout responsibility to upstrea #fastcgi_read_timeout 14400; fastcgi_index index.php; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
php.conf
location ~ \.php { # for security reasons the next line is highly encouraged try_files $uri =404; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_NAME $fastcgi_script_name; # if the next line in yours still contains $document_root # consider switching to $request_filename provides # better support for directives such as alias fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; # If using a unix socket... fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; # fastcgi_pass unix:/tmp/php5-fpm.sock; # If using a TCP connection... # fastcgi_pass 127.0.0.1:9000; }
blacklist.conf
map $http_user_agent $bad_bot { default 0; ~*^Lynx 0; # Let Lynx go through libwww-perl 1; ~(?i)(httrack|htmlparser|libwww) 1; } ## Add here all referrers that are to blocked. map $http_referer $bad_referer { default 0; ~(?i)(babes|click|diamond|forsale|girl|jewelry|love|nudit|organic|poker|porn|poweroversoftware|sex|teen|webcam|zippo|casino|replica) 1; }