Guest User

drupal.conf

a guest
Jun 17th, 2011
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | None | 0 0
  1. #######################################################
  2. ### nginx.conf catch-all
  3. #######################################################
  4.  
  5. client_max_body_size 75M;
  6.  
  7. gzip_static on;
  8. gzip on;
  9. gzip_comp_level 9;
  10. gzip_types application/x-javascript text/css text/plain text/xml application/xml application/xml+rss text/javascript;
  11.  
  12. location = /favicon.ico {
  13. log_not_found off;
  14. access_log off;
  15. }
  16.  
  17. location = /robots.txt {
  18. allow all;
  19. log_not_found off;
  20. access_log off;
  21. }
  22.  
  23. # This is mostly based on Drupal's stock .htaccess
  24. location ~* ^.+(\.(txt|engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)|code-style\.pl|/Entries.*|/Repository|/Root|/Tag|/Template)$ {
  25. return 404;
  26. }
  27.  
  28. # serve static files directly
  29. location ~* ^.+\.(jpg|jpeg|gif|png|ico|swf|flv)$ {
  30. access_log off;
  31. expires 30d;
  32. }
  33.  
  34. # Very rarely should these ever be accessed outside of your lan
  35. location ~* \.(txt|log)$ {
  36. allow 192.168.0.0/16;
  37. deny all;
  38. }
  39.  
  40. location ~ \..*/.*\.php$ {
  41. return 403;
  42. }
  43.  
  44. ## Deny some crawlers
  45. if ($http_user_agent ~* (HTTrack|HTMLParser|libwww) ) {
  46. return 444;
  47. }
  48.  
  49. ## Deny certain Referers (case insensitive)
  50. if ($http_referer ~* (poker|sex|girl) ) {
  51. return 444;
  52. }
  53.  
  54. ## 6.x starts
  55. location / {
  56. rewrite ^/(.*)/$ /$1 permanent; # remove trailing slashes - disabled
  57. try_files $uri @cache;
  58. }
  59.  
  60. location @cache {
  61. if ( $request_method !~ ^(GET|HEAD)$ ) {
  62. return 405;
  63. }
  64.  
  65. if ($http_cookie ~ "DRUPAL_UID") {
  66. return 405;
  67. }
  68.  
  69. error_page 405 = @drupal;
  70. add_header Expires "Tue, 24 Jan 1984 08:00:00 GMT";
  71. add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
  72. add_header X-Header "Boost Citrus 1.9";
  73. charset utf-8;
  74. try_files /cache/normal/$host${uri}_$args.html /cache/$host${uri}_$args.html @drupal;
  75. }
  76.  
  77. location @drupal {
  78. rewrite ^/(.*)$ /index.php?q=$1 last;
  79. }
  80.  
  81. location ~* (/\..*|settings\.php$|\.(htaccess|engine|inc|info|install|module|profile|pl|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(Entries.*|Repository|Root|Tag|Template))$ {
  82. deny all;
  83. }
  84.  
  85. location ~* /files/.*\.php$ {
  86. return 444;
  87. }
  88.  
  89. location ~* /themes/.*\.php$ {
  90. return 444;
  91. }
  92.  
  93. location ~ \.css$ {
  94. if ( $request_method !~ ^(GET|HEAD)$ ) {
  95. return 405;
  96. }
  97.  
  98. if ($http_cookie ~ "DRUPAL_UID") {
  99. return 405;
  100. }
  101.  
  102. error_page 405 = @uncached;
  103. access_log off;
  104. expires max; #if using aggregator
  105. add_header X-Header "Boost Citrus 2.1";
  106. try_files /cache/perm/$host${uri}_.css /cache/$host${uri}_.css $uri =404;
  107. }
  108.  
  109. location ~ \.js$ {
  110. if ( $request_method !~ ^(GET|HEAD)$ ) {
  111. return 405;
  112. }
  113.  
  114. if ($http_cookie ~ "DRUPAL_UID") {
  115. return 405;
  116. }
  117.  
  118. error_page 405 = @uncached;
  119. access_log off;
  120. expires max; # if using aggregator
  121. add_header X-Header "Boost Citrus 2.2";
  122. try_files /cache/perm/$host${uri}_.js /cache/$host${uri}_.js $uri =404;
  123. }
  124.  
  125. location ~ \.json$ {
  126. if ( $request_method !~ ^(GET|HEAD)$ ) {
  127. return 405;
  128. }
  129.  
  130. if ($http_cookie ~ "DRUPAL_UID") {
  131. return 405;
  132. }
  133.  
  134. error_page 405 = @uncached;
  135. access_log off;
  136. expires max; # if using aggregator
  137. add_header X-Header "Boost Citrus 2.3";
  138. try_files /cache/normal/$host${uri}_.json /cache/$host${uri}_.json $uri =404;
  139. }
  140.  
  141. location @uncached {
  142. access_log off;
  143. expires max; # max if using aggregator, otherwise sane expire time
  144. }
  145.  
  146. location ^~ /sites/default/files/imagecache/ {
  147. index index.php index.html;
  148.  
  149. # assume a clean URL is requested, and rewrite to index.php
  150. if (!-e $request_filename) {
  151. rewrite ^/(.*)$ /index.php?q=$1 last;
  152. break;
  153. }
  154. }
  155.  
  156. location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ {
  157. access_log off;
  158. expires max;
  159. try_files $uri =404;
  160. }
  161.  
  162. location ~* \.xml$ {
  163. if ( $request_method !~ ^(GET|HEAD)$ ) {
  164. return 405;
  165. }
  166. if ($http_cookie ~ "DRUPAL_UID") {
  167. return 405;
  168. }
  169. error_page 405 = @drupal;
  170. add_header Expires "Tue, 24 Jan 1984 08:00:00 GMT";
  171. add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
  172. add_header X-Header "Boost Citrus 2.4";
  173. charset utf-8;
  174. types { }
  175. default_type application/rss+xml;
  176. try_files /cache/normal/$host${uri}_.xml /cache/normal/$host${uri}_.html /cache/$host${uri}_.xml $uri @drupal;
  177. }
  178.  
  179. location ~* /feed$ {
  180. if ( $request_method !~ ^(GET|HEAD)$ ) {
  181. return 405;
  182. }
  183. if ($http_cookie ~ "DRUPAL_UID") {
  184. return 405;
  185. }
  186. error_page 405 = @drupal;
  187. add_header Expires "Tue, 24 Jan 1984 08:00:00 GMT";
  188. add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
  189. add_header X-Header "Boost Citrus 2.5";
  190. charset utf-8;
  191. types { }
  192. default_type application/rss+xml;
  193. try_files /cache/normal/$host${uri}_.xml /cache/normal/$host${uri}_.html /cache/$host${uri}_.xml $uri @drupal;
  194. }
  195.  
  196. #######################################################
  197. ### nginx.conf catch-all
  198. #######################################################
Add Comment
Please, Sign In to add comment