6RUN0

nginx.conf

Feb 23rd, 2013
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1.  
  2. #user nobody;
  3. worker_processes 2;
  4.  
  5. error_log /var/log/nginx/error.log;
  6. #error_log logs/error.log notice;
  7. #error_log logs/error.log info;
  8.  
  9. pid /var/run/nginx.pid;
  10.  
  11. events {
  12. worker_connections 1024;
  13. }
  14.  
  15. http {
  16. include mime.types;
  17. default_type application/octet-stream;
  18. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  19. # '$status $body_bytes_sent "$http_referer" '
  20. # '"$http_user_agent" "$http_x_forwarded_for"';
  21. access_log /var/log/nginx/access.log;
  22.  
  23. sendfile on;
  24. tcp_nopush on;
  25.  
  26. #keepalive_timeout 0;
  27. keepalive_timeout 65;
  28. gzip on;
  29.  
  30. # drupal host's
  31. server {
  32. listen 127.0.0.1:80;
  33. server_name ~^(www\.)?(?<domain>.+)$;
  34. root /home/www/drupal/$domain/public_html;
  35. #charset utf-8;
  36. access_log /home/www/drupal/$domain/logs/access.log;
  37. client_max_body_size 0;
  38. location @rewrite {
  39. # Some modules enforce no slash (/) at the end of the URL
  40. # Else this rewrite block wouldn't be needed (GlobalRedirect)
  41. rewrite ^/(.*)$ /index.php?q=$1;
  42. }
  43. location / {
  44. # This is cool because no php is touched for static content
  45. try_files $uri @rewrite;
  46. }
  47. # Fighting with ImageCache? This little gem is amazing.
  48. location ~ ^/sites/.*/files/imagecache/ {
  49. try_files $uri @rewrite;
  50. }
  51. # Patch image styles for D7 too.
  52. location ~ ^/sites/.*/files/styles/ {
  53. try_files $uri @rewrite;
  54. }
  55. location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
  56. expires max;
  57. log_not_found off;
  58. }
  59. location ~ \..*/.*\.php$ {
  60. return 403;
  61. }
  62. location = /favicon.ico {
  63. log_not_found off;
  64. access_log off;
  65. }
  66. location = /robots.txt {
  67. allow all;
  68. log_not_found off;
  69. access_log off;
  70. }
  71. # Very rarely should these ever be accessed outside of your lan
  72. location ~* \.(txt|log)$ {
  73. allow 127.0.0.0/8;
  74. deny all;
  75. }
  76. location ~ \.php$ {
  77. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  78. include fastcgi_params;
  79. #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
  80. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  81. fastcgi_intercept_errors on;
  82. fastcgi_read_timeout 300;
  83. fastcgi_hide_header X-Powered-By;
  84. fastcgi_pass unix:/var/run/php/php-fpm.sock;
  85. }
  86. # deny access to .htaccess files, if Apache's document root
  87. # concurs with nginx's one
  88. location ~/\.ht {
  89. deny all;
  90. }
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment