Advertisement
Guest User

Untitled

a guest
May 1st, 2016
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. # You may add here your
  2. # server {
  3. # ...
  4. # }
  5. # statements for each of your virtual hosts
  6.  
  7. server {
  8.  
  9. listen 80; ## listen for ipv4
  10. # listen [::]:80 default ipv6only=on; ## listen for ipv6
  11.  
  12. server_name forum.maybe.ru www.forum.maybe.ru;
  13. set $main_host 'forum.maybe.ru';
  14.  
  15. #Делаем, чтобы сайт не открывался по IP
  16. if ($http_host ~ "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}") {
  17. return 444;
  18. }
  19.  
  20. if ($host != $main_host) {
  21. rewrite ^(.*)$ http://$main_host$1 permanent;
  22. break;
  23. }
  24.  
  25. access_log /var/log/nginx/localhost.access.log;
  26. error_log /var/log/nginx/forum.maybe.ru.error.log;
  27.  
  28. root /var/www/$main_host/www;
  29. index index.php index.html index.htm;
  30.  
  31. ## Disable viewing .htaccess & .htpassword
  32. location ~ /\.ht {
  33. deny all;
  34. }
  35.  
  36. if ($http_user_agent ~* "WordPress") {
  37. return 444;
  38. }
  39.  
  40. location / {
  41. index index.php index.html index.htm;
  42. try_files $uri $uri/ /index.php?q=$uri&$args;
  43. }
  44.  
  45. location ~ \.php$ {
  46. include /etc/nginx/conf/fastcgi_params.conf;
  47.  
  48. fastcgi_param SCRIPT_FILENAME /var/www/$main_host/www$fastcgi_script_name;
  49. fastcgi_param DOCUMENT_ROOT /var/www/$main_host/www;
  50.  
  51. fastcgi_param PHP_ADMIN_VALUE upload_tmp_dir=/var/www/$main_host/tmp/upload;
  52. fastcgi_param PHP_ADMIN_VALUE session.save_path=/var/www/$main_host/tmp/sessions;
  53. }
  54.  
  55. location = /favicon.ico {
  56. try_files /favicon.ico @favicon_empty;
  57. expires 7d;
  58. access_log off;
  59. log_not_found off;
  60. }
  61.  
  62. location @favicon_empty {
  63. empty_gif;
  64. expires 7d;
  65. access_log off;
  66. log_not_found off;
  67. }
  68.  
  69. location ~* ^.+\.(ico|htm|html|txt|jpg|png|gif|css|js)$ {
  70. access_log off;
  71. autoindex off;
  72. expires 30d;
  73. add_header Cache-Control 'public';
  74. }
  75.  
  76. location = /robots.txt {
  77. allow all;
  78. log_not_found off;
  79. access_log off;
  80. }
  81.  
  82. location ~ /\. {
  83. deny all;
  84. access_log off;
  85. log_not_found off;
  86. }
  87.  
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement