nginx.conf 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. server
  2. {
  3. listen 80;
  4. listen [::]:80;
  5. server_name 0.0.0.0;
  6. index index.html;
  7. root /app;
  8. #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
  9. #error_page 404/404.html;
  10. #SSL-END
  11. #ERROR-PAGE-START 错误页配置,可以注释、删除或修改
  12. #error_page 404 /404.html;
  13. #error_page 502 /502.html;
  14. #ERROR-PAGE-END
  15. #PHP-INFO-START PHP引用配置,可以注释或修改
  16. #include enable-php-00.conf;
  17. #PHP-INFO-END
  18. #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
  19. #include /www/server/panel/vhost/rewrite/rewrite.conf;
  20. #REWRITE-END
  21. #禁止访问的文件或目录
  22. location ~ ^/(\.user.ini|\.htaccess|\.git|\.env|\.svn|\.project|LICENSE|README.md)
  23. {
  24. return 404;
  25. }
  26. #一键申请SSL证书验证目录相关设置
  27. location ~ \.well-known{
  28. allow all;
  29. }
  30. location /pub {
  31. autoindex on; #开启索引功能
  32. autoindex_exact_size off;
  33. autoindex_localtime on;
  34. add_before_body /.autoindex/header.html;
  35. add_after_body /.autoindex/footer.html;
  36. charset utf-8;
  37. }
  38. #禁止在证书验证目录放入敏感文件
  39. if ( $uri ~ "^/\.well-known/.*\.(php|jsp|py|js|css|lua|ts|go|zip|tar\.gz|rar|7z|sql|bak)$" ) {
  40. return 403;
  41. }
  42. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  43. {
  44. expires 30d;
  45. error_log /dev/null;
  46. access_log /dev/null;
  47. }
  48. location ~ .*\.(js|css)?$
  49. {
  50. expires 12h;
  51. error_log /dev/null;
  52. access_log /dev/null;
  53. }
  54. }