1. #www.521php.com
  2. server
  3. {
  4. listen 80;
  5. server_name www.521php.com;
  6. rewrite ^(.*)$ https://$host$1 permanent;
  7. }
  8. server {
  9. listen 443 ssl;
  10. ssl_certificate /home/cert/521php.com_2022.crt;
  11. ssl_certificate_key /home/cert/521php.com_2022.key;
  12. server_name www.demo.com www.521php.com;
  13. location / {
  14. root /usr/share/nginx/html/521php; # 代码目录
  15. index index.html index.htm index.php; # 增加index.php
  16. try_files $uri $uri/ /index.php?$args;
  17. }
  18. # error_page 404 /404.html;
  19. # location = /40x.html {
  20. # root /usr/share/nginx/html;
  21. # }
  22. # # redirect server error pages to the static page /50x.html
  23. # error_page 500 502 503 504 /50x.html;
  24. # location = /50x.html {
  25. # root /usr/share/nginx/html;
  26. # }
  27. location ~ \.php$ {
  28. root /var/www/521php; # 代码目录
  29. fastcgi_pass 521php_php:9000; # compose文件中nginx段设置的links的php名称
  30. fastcgi_index index.php;
  31. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # 修改为$document_root
  32. include fastcgi_params;
  33. }
  34. }