全球主机交流论坛

标题: CHEVERETO在Nginx環境的Nginx虛擬主機中有一段僞靜態無法添加 [打印本页]

作者: httpd    时间: 2025-1-6 21:20
标题: CHEVERETO在Nginx環境的Nginx虛擬主機中有一段僞靜態無法添加
  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報錯,無法啓動
作者: NodeLoc    时间: 2025-1-6 21:22
删掉就好了 这一段没用
作者: httpd    时间: 2025-1-6 21:24
NodeLoc 发表于 2025-1-6 21:22
删掉就好了 这一段没用

真的嗎?我看注釋寫的作用是禁用直接訪問php文件
作者: NodeLoc    时间: 2025-1-6 21:28
PHP文件直接访问也没用啊 没用的
作者: ncsccc    时间: 2025-1-6 21:29
  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. }
复制代码



我的
作者: httpd    时间: 2025-1-6 21:33
ncsccc 发表于 2025-1-6 21:29
我的

是V3.20.20嗎
作者: httpd    时间: 2025-1-6 21:35
NodeLoc 发表于 2025-1-6 21:28
PHP文件直接访问也没用啊 没用的

哦哦
作者: ncsccc    时间: 2025-1-6 21:36
httpd 发表于 2025-1-6 21:33
是V3.20.20嗎

是的
作者: httpd    时间: 2025-1-6 21:42
ncsccc 发表于 2025-1-6 21:36
是的

好簡潔




欢迎光临 全球主机交流论坛 (https://loc.442266.xyz/) Powered by Discuz! X3.4