Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fastcgi_cache_path /etc/nginx/cache/abc levels=1:2 keys_zone=ABC:100m inactive=60m;
- add_header X-Cache $upstream_cache_status;
- server {
- listen 80; ## listen for ipv4; this line is default and implied
- root /var/www/abc/public_html;
- index index.php index.html index.htm;
- server_name abc.com www.abc.com;
- location / {
- try_files $uri $uri/ /index.php?q=$uri&$args;
- # FastCGI Rules
- set $no_cache 0;
- if ($request_method = POST) {
- set $no_cache 1;
- }
- if ($query_string != "") {
- set $no_cache 1;
- }
- if ($request_uri ~* "(/admin.php|/admin/|/adminitrator|/login.php|/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 $no_cache 1;
- }
- if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
- set $no_cache 1;
- }
- #Don't cache if there is a cookie called PHPSESSID
- if ($http_cookie = "PHPSESSID")
- {
- set $no_cache 1;
- }
- }
- location /doc/ {
- alias /usr/share/doc/;
- autoindex on;
- allow 127.0.0.1;
- deny all;
- }
- error_page 404 /404.html;
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /usr/share/nginx/www;
- }
- location ~ \.php$ {
- try_files $uri =404;
- fastcgi_pass unix:/var/run/php5-fpm.sock;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- include fastcgi_params;
- fastcgi_cache ABC;
- fastcgi_cache_valid 200 60m;
- fastcgi_cache_bypass $no_cache;
- fastcgi_no_cache $no_cache;
- fastcgi_cache_key "$scheme$request_method$host$request_uri";
- fastcgi_cache_use_stale error timeout invalid_header http_500;
- }
- # Purge settings
- location ~ /purge(/.*) {
- fastcgi_cache_purge ABC "$scheme$request_method$host$1";
- }
- location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|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 = /robots.txt { access_log off; log_not_found off; }
- location ~ /\. { deny all; access_log off; log_not_found off; }
- #Header Expiry
- location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
- access_log off;
- log_not_found off;
- expires 360d;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement