Advertisement
Guest User

drupal_nginx_conf

a guest
Jul 6th, 2013
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. server {
  2. listen 80; ## listen for IPv4
  3. listen [::]:80 default ipv6only=on; ## listen for IPv6
  4.  
  5. server_name main;
  6. root /usr/share/drupal7; ## <-- Your only path reference.
  7. index index.php;
  8.  
  9. ## Access and error logs.
  10. access_log /var/log/nginx/drupal_access.log;
  11. error_log /var/log/nginx/drupal_error.log;
  12.  
  13. include apps/drupal/drupal_upload_progress.conf;
  14.  
  15. location = /favicon.ico {
  16. log_not_found off;
  17. access_log off;
  18. }
  19.  
  20. location = /robots.txt {
  21. allow all;
  22. log_not_found off;
  23. access_log off;
  24. }
  25.  
  26. location ~ \..*/.*\.php$ {
  27. return 403;
  28. }
  29.  
  30. # No no for private
  31. location ~ ^/sites/.*/private/ {
  32. return 403;
  33. }
  34.  
  35. # Block access to "hidden" files and directories whose names begin with a
  36. # period. This includes directories used by version control systems such
  37. # as Subversion or Git to store control files.
  38. location ~ (^|/)\. {
  39. return 403;
  40. }
  41.  
  42. location / {
  43. # This is cool because no php is touched for static content
  44. try_files $uri @cache;
  45. }
  46.  
  47. location /sub1 {
  48. rewrite ^/([^/]*)/(.*)(/?)$ /$1/index.php?q=$2&$args;
  49. try_files $uri $uri/ @cache;
  50. }
  51.  
  52. location /sub2 {
  53. rewrite ^/([^/]*)/(.*)(/?)$ /$1/index.php?q=$2&$args;
  54. try_files $uri $uri/ @cache;
  55. }
  56.  
  57. location @drupal {
  58. rewrite ^ /index.php;
  59. }
  60.  
  61. location ~ \.php$ {
  62. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  63. #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
  64. include fastcgi_params;
  65. fastcgi_param SCRIPT_FILENAME $request_filename;
  66. fastcgi_intercept_errors on;
  67. fastcgi_pass phpcgi;
  68. include apps/drupal/microcache_fcgi_auth.conf;
  69. track_uploads uploads 60s;
  70. }
  71.  
  72. location ~ ^/sites/.*/files/styles/ {
  73. try_files $uri @drupal;
  74. }
  75.  
  76. location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
  77. expires max;
  78. log_not_found off;
  79. }
  80.  
  81. location @cache {
  82. ## Boost compresses can the pages so we check it. Comment it out
  83. ## if you don't have it enabled in Boost.
  84. gzip_static on;
  85. ## Error page handler for the case where $no_cache is 1. POST
  86. ## request or authenticated.
  87. error_page 418 = @drupal;
  88.  
  89. ## If $no_cache is 1 then it means that either we have a session
  90. ## cookie or that the request method is POST. So serve the dynamic
  91. ## page.
  92. if ($no_cache) {
  93. return 418; # I'm a teapot/I can't get no cachifaction
  94. }
  95.  
  96. ## No caching for POST requests.
  97. if ($request_method = POST) {
  98. return 418;
  99. }
  100.  
  101. # Now for some header tweaking. We use a date that differs
  102. # from stock Drupal. Everyone seems to be using their
  103. # birthdate. Why go against the grain?
  104. add_header Expires "Tue, 13 Jun 1977 03:45:00 GMT";
  105. # We bypass all delays in the post-check and pre-check
  106. # parameters of Cache-Control. Both set to 0.
  107.  
  108. add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
  109. # Funny...perhaps. Egocentric? Damn right!;
  110. add_header X-Header "Boost Helás Avril 1.0";
  111. ## Boost doesn't set a charset.
  112. charset utf-8;
  113.  
  114. # We try each boost URI in succession, if every one of them
  115. # fails then relay to Drupal.
  116. try_files /cache/normal/$host${uri}_${args}.html /cache/perm/$host${uri}_.css /cache/perm/$host${uri}_.js /cache/$host/0$uri.html /cache/$host/0${uri}/index.html @drupal;
  117. }
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement