Advertisement
Guest User

nginx

a guest
Nov 14th, 2011
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 KB | None | 0 0
  1. # W3TC config rules based on http://elivz.com/blog/single/wordpress_with_w3tc_on_nginx/
  2. server {
  3. listen 80; ## listen for ipv4; this line is default and implied
  4. #listen [::]:80 default ipv6only=on; ## listen for ipv6
  5. # Tell nginx to handle requests for the www.engin.ex domain
  6. server_name www.engin.ex engin.ex;
  7. if ($host != 'engin.ex') {
  8. rewrite ^/(.*) http://engin.ex/$1 permanent;
  9. }
  10. index index.php index.html index.htm;
  11. root /srv/www/engin.ex/public_html;
  12. access_log /srv/www/engin.ex/logs/access.log;
  13. error_log /srv/www/engin.ex/logs/error.log;
  14. # Use gzip compression
  15. # gzip_static on; # Uncomment if you compiled Nginx using --with-http_gzip_static_module
  16. gzip on;
  17. gzip_disable "msie6";
  18. gzip_vary on;
  19. gzip_proxied any;
  20. gzip_comp_level 5;
  21. gzip_buffers 16 8k;
  22. gzip_http_version 1.0;
  23. gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript image/png image/gif image/jpeg;
  24. # Rewrite minified CSS and JS files
  25. rewrite ^/wp-content/w3tc/min/([a-f0-9]+)\/(.+)\.(include(\-(footer|body))?(-nb)?)\.[0-9]+\.(css|js)$ /wp-content/w3tc/min/index.php?tt=$1&gg=$2&g=$3&t=$7 last;
  26. # Set a variable to work around the lack of nested conditionals
  27. set $cache_uri $request_uri;
  28. # POST requests and urls with a query string should always go to PHP
  29. if ($request_method = POST) {
  30. set $cache_uri 'no cache';
  31. }
  32. if ($query_string != "") {
  33. set $cache_uri 'no cache';
  34. }
  35. # Don't cache uris containing the following segments
  36. if ($request_uri ~* "(\/wp-admin\/|\/xmlrpc.php|\/wp-(app|cron|login|register|mail)\.php|wp-.*\.php|index\.php|wp\-comments\-popup\.php|wp\-links\-opml\.php|wp\-locations\.php)") {
  37. set $cache_uri "no cache";
  38. }
  39. # Don't use the cache for logged in users or recent commenters
  40. if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp\-postpass|wordpress_logged_in") {
  41. set $cache_uri 'no cache';
  42. }
  43. # similar to Apache Status - handy for quickly checking the health of nginx
  44. location /nginx_status {
  45. stub_status on;
  46. access_log off;
  47. allow all;
  48. }
  49. # Use cached or actual file if they exists, otherwise pass request to WordPress
  50. location / {
  51. try_files /wp-content/w3tc/pgcache/$cache_uri/_index.html $uri $uri/ /index.php;
  52. }
  53. # Cache static files for as long as possible - removed xml as an extension to avoid problems with Yoast WordPress SEO plugin which uses WP rewrite API.
  54. location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
  55. try_files $uri =404;
  56. expires max;
  57. access_log off;
  58. }
  59. location / {
  60. try_files $uri $uri/ /index.php?q=$uri&$args;
  61. }
  62. # Deny access to hidden files
  63. location ~* /\.ht {
  64. deny all;
  65. access_log off;
  66. log_not_found off;
  67. }
  68. # Pass PHP scripts on to PHP-FPM
  69. location ~* \.php$ {
  70. try_files $uri /index.php;
  71. fastcgi_index index.php;
  72. fastcgi_pass 127.0.0.1:9000;
  73. include fastcgi_params;
  74. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  75. fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  76. }
  77. }
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement