主机论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 264|回复: 8

CHEVERETO在Nginx環境的Nginx虛擬主機中有一段僞靜態無法添加

[复制链接]

433

主题

911

回帖

3707

积分

论坛元老

Rank: 8Rank: 8

积分
3707
发表于 2025-1-6 21:20:36 | 显示全部楼层 |阅读模式
  1. # Disable access to sensitive application files
  2. location ~* (app|content|lib)/.*\.(po|php|lock|sql)$ {
  3. return 404;
  4. }
  5. location ~* composer\.json|composer\.lock|.gitignore$ {
  6. return 404;
  7. }
  8. location ~* /\.ht {
  9. return 404;
  10. }

  11. # Image not found replacement
  12. location ~* \.(jpe?g|png|gif|webp)$ {
  13. log_not_found off;
  14. error_page 404 /content/images/system/default/404.gif;
  15. }

  16. # CORS header (avoids font rendering issues)
  17. location ~* \.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$ {
  18. add_header Access-Control-Allow-Origin "*";
  19. }

  20. # PHP front controller
  21. location / {
  22. index index.php;
  23. try_files $uri $uri/ /index.php$is_args$query_string;
  24. }

  25. # Single PHP-entrypoint (disables direct access to .php files)
  26. location ~* \.php${
  27. internal;
  28. include snippets/fastcgi-php.conf;
  29. fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
  30. }
复制代码


就是這一段中的
  1. # Single PHP-entrypoint (disables direct access to .php files)
  2. location ~* \.php${
  3. internal;
  4. include snippets/fastcgi-php.conf;
  5. fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
  6. }
复制代码

這段添加進去Nginx報錯,無法啓動
回复

使用道具 举报

128

主题

852

回帖

2474

积分

金牌会员

Rank: 6Rank: 6

积分
2474
发表于 2025-1-6 21:22:14 | 显示全部楼层
删掉就好了 这一段没用
回复

使用道具 举报

433

主题

911

回帖

3707

积分

论坛元老

Rank: 8Rank: 8

积分
3707
 楼主| 发表于 2025-1-6 21:24:03 | 显示全部楼层
NodeLoc 发表于 2025-1-6 21:22
删掉就好了 这一段没用

真的嗎?我看注釋寫的作用是禁用直接訪問php文件
回复

使用道具 举报

128

主题

852

回帖

2474

积分

金牌会员

Rank: 6Rank: 6

积分
2474
发表于 2025-1-6 21:22:00 | 显示全部楼层
PHP文件直接访问也没用啊 没用的
回复

使用道具 举报

2

主题

36

回帖

124

积分

注册会员

Rank: 2

积分
124
发表于 2025-1-6 21:28:58 | 显示全部楼层
  1. location / {
  2. if (-f $request_filename/index.html){
  3. rewrite (.*) $1/index.html break;
  4. }
  5. if (-f $request_filename/index.php){
  6. rewrite (.*) $1/index.php;
  7. }
  8. if (!-f $request_filename){
  9. rewrite (.*) /index.php;
  10. }
  11. try_files $uri $uri/ /api.php;
  12. }
  13. location /admin {
  14. try_files $uri /admin/index.php?$args;
  15. }
复制代码



我的
回复

使用道具 举报

433

主题

911

回帖

3707

积分

论坛元老

Rank: 8Rank: 8

积分
3707
 楼主| 发表于 2025-1-6 21:29:12 | 显示全部楼层

是V3.20.20嗎
回复

使用道具 举报

433

主题

911

回帖

3707

积分

论坛元老

Rank: 8Rank: 8

积分
3707
 楼主| 发表于 2025-1-6 21:33:44 | 显示全部楼层
NodeLoc 发表于 2025-1-6 21:28
PHP文件直接访问也没用啊 没用的

哦哦
回复

使用道具 举报

2

主题

36

回帖

124

积分

注册会员

Rank: 2

积分
124
发表于 2025-1-6 21:29:00 | 显示全部楼层

是的
回复

使用道具 举报

433

主题

911

回帖

3707

积分

论坛元老

Rank: 8Rank: 8

积分
3707
 楼主| 发表于 2025-1-6 21:35:12 | 显示全部楼层
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|主机论坛

GMT+8, 2025-5-15 08:58 , Processed in 0.072236 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表