Advertisement
nimopress

vhost

Oct 28th, 2013
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.24 KB | None | 0 0
  1. server {
  2. listen 80;
  3. root /var/www/mydomain.com/htdocs;
  4. index index.php index.html index.htm;
  5. server_name mydomain.com www.mydomain.com;
  6. error_log /var/log/nginx/mydomain.com.error.log debug;
  7.  
  8. # FarInSpace - enforce NO www (Pretty URL)
  9. if ($host ~* ^www\.(.*))
  10. {
  11. set $host_without_www $1;
  12. rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
  13. }
  14.  
  15. # FarInSpace - unless the request is for a valid file, send to bootstrap (Pretty URL)
  16. if (!-e $request_filename)
  17. {
  18. rewrite ^(.+)$ /index.php?q=$1 last;
  19. }
  20.  
  21. # Yoast - Rewrites for WordPress SEO XML Sitemap
  22. rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
  23. rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
  24.  
  25. # RTCamp set cache url and request url
  26. set $cache_uri $request_uri;
  27.  
  28. # W3TC Rewrite - Page Disk Enhanced settings starts from /wp-content...
  29. # RTCamp - WordPress Use cached or actual file if they exists, otherwise pass request to WordPress
  30. location / {
  31. try_files $uri $uri/ /index.php?q=$uri&$args /wp-content/cache/page_enhanced/${host}${cache_uri}_index.html $uri $uri/ /index.php?$args ;
  32. }
  33.  
  34. error_page 404 /404.html;
  35. error_page 500 502 503 504 /50x.html;
  36. location = /50x.html {
  37. root /usr/share/nginx/html;
  38. }
  39.  
  40. # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  41. location ~ \.php$ {
  42. ##
  43. # WordPress PHP
  44. ##
  45. try_files $uri /index.php =404;
  46. #fastcgi_pass 127.0.0.1:9000;
  47. # With php5-fpm:
  48. fastcgi_pass unix:/var/run/php5-fpm.sock;
  49. fastcgi_index index.php;
  50. include fastcgi_params;
  51.  
  52. ##
  53. # BEGIN FastCGI Cache/Buffer
  54. ##
  55. # HowToForge
  56. #include /etc/nginx/fastcgi_params;
  57. #fastcgi_pass unix:/var/lib/php5-fpm/web1.sock;
  58. #fastcgi_index index.php;
  59. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  60. fastcgi_param PATH_INFO $fastcgi_script_name;
  61. fastcgi_intercept_errors off;
  62. fastcgi_buffers 8 16k;
  63. fastcgi_buffer_size 32k;
  64. fastcgi_busy_buffers_size 32k;
  65. fastcgi_temp_file_write_size 32k;
  66. fastcgi_read_timeout 240;
  67. # HowToForge
  68. # seravo
  69. set $skip_cache 1;
  70. if ($cache_uri != "null cache") {
  71. add_header X-Cache-Debug "$cache_uri $cookie_nocache $arg_nocache$arg_comment $http_pragma $http_authorization";
  72. set $skip_cache 0;
  73. }
  74. fastcgi_cache_bypass $skip_cache;
  75. fastcgi_cache microcache;
  76. fastcgi_cache_key $scheme$host$request_uri$request_method;
  77. fastcgi_cache_valid any 8m;
  78. fastcgi_cache_bypass $http_pragma;
  79. fastcgi_cache_use_stale updating error timeout invalid_header http_500;
  80. # seravo
  81. ##
  82. # END FastCGI Cache/Buffer
  83. ##
  84.  
  85. }
  86.  
  87. # RTCamp - WordPress POST requests and urls with a query string should always go to PHP
  88. if ($request_method = POST) {
  89. set $cache_uri 'null cache';
  90. }
  91. if ($query_string != "") {
  92. set $cache_uri 'null cache';
  93. }
  94.  
  95. # RTCamp - WordPress Don't cache uris containing the following segments
  96. 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-
  97.  
  98. 9_-]+-sitemap([0-9]+)?.xml)") {
  99. set $cache_uri 'null cache';
  100. }
  101. # RTCamp - WordPress Don't use the cache for logged in users or recent commenters
  102. if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
  103. set $cache_uri 'null cache';
  104. }
  105.  
  106. # W3TC Rewrite - Minify or handled by WordPress if not available
  107. location ~ ^/wp-content/cache/minify/[^/]+/(.*)$ {
  108. try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1;
  109. }
  110.  
  111. # HowToForge - Cache static files for as long as possible
  112. location ~* \.(?:js|css|jpg|jpeg|gif|png|ico|mp4|wav|ogg|ogv)$ {
  113. expires max; log_not_found off; access_log off; add_header Pragma public;
  114. add_header Cache-Control "public, must-revalidate, proxy-revalidate";
  115. }
  116.  
  117. # remove the robots line if you want to use wordpress' virtual robots.txt
  118. location = /favicon.ico { log_not_found off; access_log off; }
  119. location = /robots.txt { log_not_found off; access_log off; }
  120.  
  121. # this prevents hidden files (beginning with a period) from being served
  122. location ~ /\. { deny all; access_log off; log_not_found off; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement