Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- server {
- listen 80;
- root /var/www/mydomain.com/htdocs;
- index index.php index.html index.htm;
- server_name mydomain.com www.mydomain.com;
- error_log /var/log/nginx/mydomain.com.error.log debug;
- # FarInSpace - enforce NO www (Pretty URL)
- if ($host ~* ^www\.(.*))
- {
- set $host_without_www $1;
- rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
- }
- # FarInSpace - unless the request is for a valid file, send to bootstrap (Pretty URL)
- if (!-e $request_filename)
- {
- rewrite ^(.+)$ /index.php?q=$1 last;
- }
- # Yoast - Rewrites for WordPress SEO XML Sitemap
- rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
- rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
- # RTCamp set cache url and request url
- set $cache_uri $request_uri;
- # W3TC Rewrite - Page Disk Enhanced settings starts from /wp-content...
- # RTCamp - WordPress Use cached or actual file if they exists, otherwise pass request to WordPress
- location / {
- try_files $uri $uri/ /index.php?q=$uri&$args /wp-content/cache/page_enhanced/${host}${cache_uri}_index.html $uri $uri/ /index.php?$args ;
- }
- error_page 404 /404.html;
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /usr/share/nginx/html;
- }
- # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
- location ~ \.php$ {
- ##
- # WordPress PHP
- ##
- try_files $uri /index.php =404;
- #fastcgi_pass 127.0.0.1:9000;
- # With php5-fpm:
- fastcgi_pass unix:/var/run/php5-fpm.sock;
- fastcgi_index index.php;
- include fastcgi_params;
- ##
- # BEGIN FastCGI Cache/Buffer
- ##
- # HowToForge
- #include /etc/nginx/fastcgi_params;
- #fastcgi_pass unix:/var/lib/php5-fpm/web1.sock;
- #fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- fastcgi_param PATH_INFO $fastcgi_script_name;
- fastcgi_intercept_errors off;
- fastcgi_buffers 8 16k;
- fastcgi_buffer_size 32k;
- fastcgi_busy_buffers_size 32k;
- fastcgi_temp_file_write_size 32k;
- fastcgi_read_timeout 240;
- # HowToForge
- # seravo
- set $skip_cache 1;
- if ($cache_uri != "null cache") {
- add_header X-Cache-Debug "$cache_uri $cookie_nocache $arg_nocache$arg_comment $http_pragma $http_authorization";
- set $skip_cache 0;
- }
- fastcgi_cache_bypass $skip_cache;
- fastcgi_cache microcache;
- fastcgi_cache_key $scheme$host$request_uri$request_method;
- fastcgi_cache_valid any 8m;
- fastcgi_cache_bypass $http_pragma;
- fastcgi_cache_use_stale updating error timeout invalid_header http_500;
- # seravo
- ##
- # END FastCGI Cache/Buffer
- ##
- }
- # RTCamp - WordPress POST requests and urls with a query string should always go to PHP
- if ($request_method = POST) {
- set $cache_uri 'null cache';
- }
- if ($query_string != "") {
- set $cache_uri 'null cache';
- }
- # RTCamp - WordPress 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 cache';
- }
- # RTCamp - WordPress 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 cache';
- }
- # W3TC Rewrite - Minify or handled by WordPress if not available
- location ~ ^/wp-content/cache/minify/[^/]+/(.*)$ {
- try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1;
- }
- # HowToForge - Cache static files for as long as possible
- location ~* \.(?:js|css|jpg|jpeg|gif|png|ico|mp4|wav|ogg|ogv)$ {
- expires max; log_not_found off; access_log off; add_header Pragma public;
- add_header Cache-Control "public, must-revalidate, proxy-revalidate";
- }
- # remove the robots line if you want to use wordpress' virtual robots.txt
- location = /favicon.ico { log_not_found off; access_log off; }
- location = /robots.txt { log_not_found off; access_log off; }
- # this prevents hidden files (beginning with a period) from being served
- location ~ /\. { deny all; access_log off; log_not_found off; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement