default.conf 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. server {
  2. listen 80;
  3. server_name _;
  4. root /var/www/html/public;
  5. add_header X-Frame-Options "SAMEORIGIN";
  6. add_header X-XSS-Protection "1; mode=block";
  7. add_header X-Content-Type-Options "nosniff";
  8. index index.php;
  9. charset utf-8;
  10. location / {
  11. index index.php;
  12. if (!-e $request_filename) {
  13. rewrite ^(.*)$ /index.php?s=/$1 last;
  14. break;
  15. }
  16. }
  17. location ~ \.php(/|$) {
  18. include fastcgi_params;
  19. #ubuntu 缺少这个配置
  20. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  21. try_files $fastcgi_script_name =404;
  22. add_header logid $request_id;
  23. fastcgi_param logid $request_id;
  24. fastcgi_pass unix:/var/run/php-fpm.sock;
  25. fastcgi_index index.php;
  26. }
  27. location = /favicon.ico { access_log off; log_not_found off; }
  28. location = /robots.txt { access_log off; log_not_found off; }
  29. error_page 404 /index.php;
  30. location ~ /\.(?!well-known).* {
  31. deny all;
  32. }
  33. }