Advertisement
Guest User

Wordpress nginx config file

a guest
Aug 30th, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. # WordPress multisite subdirectory rules.
  2. # Designed to be included in any server {} block.
  3.  
  4. # This order might seem weird - this is attempted to match last if rules below fail.
  5. # http://wiki.nginx.org/HttpCoreModule
  6. location / {
  7. try_files $uri $uri/ /index.php?$args;
  8. }
  9.  
  10.  
  11. location /phpmyadmin {
  12. root /usr/share/;
  13. index index.php index.html index.htm;
  14. location ~ ^/phpmyadmin/(.+\.php)$ {
  15. # Zero-day exploit defense.
  16. # http://forum.nginx.org/read.php?2,88845,page=3
  17. # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
  18. # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross your fingers that you won't get hacked.
  19. try_files $uri =404;
  20.  
  21. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  22. include fastcgi_params;
  23. fastcgi_index index.php;
  24. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  25. # fastcgi_intercept_errors on;
  26. fastcgi_pass 127.0.0.1:9000;
  27. }
  28. location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
  29. root /usr/share/;
  30. }
  31. }
  32. location /phpMyAdmin {
  33. rewrite ^/* /phpmyadmin last;
  34. }
  35.  
  36.  
  37. # Add trailing slash to */wp-admin requests.
  38. rewrite /wp-admin$ $scheme://$host$uri/ permanent;
  39.  
  40. # Directives to send expires headers and turn off 404 error logging.
  41. location ~* \.(js|css|png|jpg|jpeg|gif|ico|mov|mp4|avi|doc|docx|pdf)$ {
  42. expires 48h;
  43. log_not_found off;
  44. }
  45.  
  46. # Pass uploaded files to wp-includes/ms-files.php.
  47. rewrite /files/$ /index.php last;
  48.  
  49. # For multisite: Use a caching plugin/script that creates symlinks to the correct subdirectory structure to get some performance gains.
  50. set $cachetest "$document_root/wp-content/cache/ms-filemap/${host}${uri}";
  51. if ($uri ~ /$) {
  52. set $cachetest "";
  53. }
  54. if (-f $cachetest) {
  55. # Rewrites the URI and stops rewrite processing so it doesn't start over and attempt to pass it to the next rule.
  56. rewrite ^ /wp-content/cache/ms-filemap/${host}${uri} break;
  57. }
  58.  
  59.  
  60.  
  61. if ($uri !~ wp-content/plugins) {
  62. rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
  63. }
  64.  
  65. # Uncomment one of the lines below for the appropriate caching plugin (if used).
  66. # include global/wordpress-ms-subdir-wp-super-cache.conf;
  67. # include global/wordpress-ms-subdir-w3-total-cache.conf;
  68.  
  69. # Rewrite multisite '.../wp-.*' and '.../*.php'.
  70. if (!-e $request_filename) {
  71. rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
  72. rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
  73. }
  74.  
  75. # Pass all .php files onto a php-fpm/php-fcgi server.
  76. location ~ \.php$ {
  77. # Zero-day exploit defense.
  78. # http://forum.nginx.org/read.php?2,88845,page=3
  79. # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
  80. # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross your fingers that you won't get hacked.
  81. try_files $uri =404;
  82.  
  83. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  84. include fastcgi_params;
  85. fastcgi_index index.php;
  86. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  87. # fastcgi_intercept_errors on;
  88. fastcgi_pass 127.0.0.1:9000;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement