nginx.conf.j2 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # https://laravel.com/docs/12.x/deployment#nginx
  2. server {
  3. listen 80;
  4. server_name {{ app_domain }};
  5. root {{ app_deploy_target | dirname }}/current/api-v8/public;
  6. add_header X-Frame-Options "SAMEORIGIN";
  7. add_header X-Content-Type-Options "nosniff";
  8. index index.php index.html;
  9. charset utf-8;
  10. gzip_comp_level 9;
  11. gzip_min_length 1k;
  12. gzip_types text/plain text/css application/xml application/javascript;
  13. gzip_vary on;
  14. client_max_body_size 512M;
  15. access_log {{ app_deploy_target | dirname }}/logs/access.log;
  16. error_log {{ app_deploy_target | dirname }}/logs/error.log warn;
  17. # access_log syslog:server=unix:/dev/log,tag={{ app_domain }},nohostname,severity=info combined;
  18. # error_log syslog:server=unix:/dev/log,tag={{ app_domain }},nohostname,severity=error;
  19. location {{ app_dashboard_base_path }}/ {
  20. alias {{ app_deploy_target | dirname }}/current/dashboard-v4/dashboard/dist/;
  21. try_files $uri $uri/ {{ app_dashboard_base_path }}/index.html;
  22. location ~* \.(css|js|png|jpg|jpeg|gif|gz|svg|mp4|ogg|ogv|webm|htc|xml|woff)$ {
  23. access_log off;
  24. expires max;
  25. }
  26. }
  27. location / {
  28. try_files $uri $uri/ /index.php?$query_string;
  29. }
  30. location = /favicon.ico { access_log off; log_not_found off; }
  31. location = /robots.txt { access_log off; log_not_found off; }
  32. error_page 404 /index.php;
  33. location ~ \.php$ {
  34. fastcgi_pass php_fpm_{{ app_php_fpm_port }};
  35. fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
  36. # for nginx v1.18
  37. # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  38. include fastcgi_params;
  39. fastcgi_hide_header X-Powered-By;
  40. }
  41. location ~ /\.(?!well-known).* {
  42. deny all;
  43. }
  44. }