全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

IP归属甄别会员请立即修改密码
查看: 261|回复: 8
打印 上一主题 下一主题

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

[复制链接]
跳转到指定楼层
1#
发表于 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報錯,無法啓動
2#
发表于 2025-1-6 21:22:14 来自手机 | 只看该作者
删掉就好了 这一段没用
3#
 楼主| 发表于 2025-1-6 21:24:03 | 只看该作者
NodeLoc 发表于 2025-1-6 21:22
删掉就好了 这一段没用

真的嗎?我看注釋寫的作用是禁用直接訪問php文件
4#
发表于 2025-1-6 21:28:58 来自手机 | 只看该作者
PHP文件直接访问也没用啊 没用的
5#
发表于 2025-1-6 21:29:12 | 只看该作者
  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. }
复制代码



我的
6#
 楼主| 发表于 2025-1-6 21:33:44 | 只看该作者

是V3.20.20嗎
7#
 楼主| 发表于 2025-1-6 21:35:12 | 只看该作者
NodeLoc 发表于 2025-1-6 21:28
PHP文件直接访问也没用啊 没用的

哦哦
8#
发表于 2025-1-6 21:36:29 | 只看该作者

是的
9#
 楼主| 发表于 2025-1-6 21:42:42 | 只看该作者
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-11-2 13:30 , Processed in 0.064208 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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