全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 297|回复: 8

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

[复制链接]
发表于 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報錯,無法啓動
发表于 2025-1-6 21:22:14 来自手机 | 显示全部楼层
删掉就好了 这一段没用
 楼主| 发表于 2025-1-6 21:24:03 | 显示全部楼层
NodeLoc 发表于 2025-1-6 21:22
删掉就好了 这一段没用

真的嗎?我看注釋寫的作用是禁用直接訪問php文件
发表于 2025-1-6 21:28:58 来自手机 | 显示全部楼层
PHP文件直接访问也没用啊 没用的
发表于 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. }
复制代码



我的
 楼主| 发表于 2025-1-6 21:33:44 | 显示全部楼层

是V3.20.20嗎
 楼主| 发表于 2025-1-6 21:35:12 | 显示全部楼层
NodeLoc 发表于 2025-1-6 21:28
PHP文件直接访问也没用啊 没用的

哦哦
发表于 2025-1-6 21:36:29 | 显示全部楼层

是的
 楼主| 发表于 2025-1-6 21:42:42 | 显示全部楼层
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-12-13 17:44 , Processed in 0.116807 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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