yourdomain.com.conf 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. server {
  2. listen 80;
  3. #listen 443 ssl http2;
  4. # 域名
  5. server_name localhost 192.168.10.86 wanggang.com www.wanggang.com;
  6. #ssl_certificate /etc/nginx/cert/domain.com.crt;
  7. #ssl_certificate_key /etc/nginx/cert/domain.com.key;
  8. #include /etc/nginx/cert/options-ssl-nginx.conf;
  9. index index.html index.htm index.php default.html default.htm default.php;
  10. root /wwwroot;
  11. # 跳转到首选域名,若是带www的,请自行加上www
  12. #if ($host != wanggang.com) {
  13. # rewrite ^(.*)$ $scheme://wanggang.com$1 permanent;
  14. #}
  15. # https 301跳转,不需要轻删除
  16. #if ($scheme = http) {
  17. # rewrite ^(.*)$ https://$host$1 permanent;
  18. #}
  19. location ~ [^/]\.php(/|$)
  20. {
  21. include /etc/nginx/conf.d/ext/header.conf;
  22. fastcgi_pass unix:/dev/shm/php-cgi.sock;
  23. #fastcgi_pass php-fpm:9000;
  24. #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  25. fastcgi_index index.php;
  26. include fastcgi.conf;
  27. }
  28. location ~* .*\.(gif|jpg|jpeg|png|bmp|jepg|css|js|ico|ogg|ogv|svg|svgz|eot|otf|woff|woff2|mp4|ttf|rss|atom|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
  29. access_log off;
  30. log_not_found off;
  31. expires 30d;
  32. }
  33. # 解决 robots漏洞
  34. location = /robots.txt {
  35. if ($http_user_agent !~* "spider|bot|Python-urllib|pycurl") {
  36. return 403;
  37. }
  38. #access_log off;
  39. log_not_found off;
  40. }
  41. location ~ /\. {
  42. deny all;
  43. #access_log off;
  44. log_not_found off;
  45. }
  46. access_log /data/log/$host.log;
  47. }