httpd 发表于 2025-1-6 21:20:36

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

[*]# Disable access to sensitive application files
[*]    location ~* (app|content|lib)/.*\.(po|php|lock|sql)$ {
[*]      return 404;
[*]    }
[*]    location ~* composer\.json|composer\.lock|.gitignore$ {
[*]      return 404;
[*]    }
[*]    location ~* /\.ht {
[*]      return 404;
[*]    }
[*]
[*]    # Image not found replacement
[*]    location ~* \.(jpe?g|png|gif|webp)$ {
[*]      log_not_found off;
[*]      error_page 404 /content/images/system/default/404.gif;
[*]    }
[*]
[*]    # CORS header (avoids font rendering issues)
[*]    location ~* \.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$ {
[*]      add_header Access-Control-Allow-Origin "*";
[*]    }
[*]
[*]    # PHP front controller
[*]    location / {
[*]      index index.php;
[*]      try_files $uri $uri/ /index.php$is_args$query_string;
[*]    }
[*]
[*]    # Single PHP-entrypoint (disables direct access to .php files)
[*]    location ~* \.php${
[*]      internal;
[*]      include snippets/fastcgi-php.conf;
[*]      fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
[*]    }复制代码

就是這一段中的
[*]    # Single PHP-entrypoint (disables direct access to .php files)
[*]    location ~* \.php${
[*]      internal;
[*]      include snippets/fastcgi-php.conf;
[*]      fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
[*]    }复制代码
這段添加進去Nginx報錯,無法啓動

NodeLoc 发表于 2025-1-6 21:22:14

删掉就好了 这一段没用

httpd 发表于 2025-1-6 21:24:03


NodeLoc 发表于 2025-1-6 21:22

删掉就好了 这一段没用
真的嗎?我看注釋寫的作用是禁用直接訪問php文件

NodeLoc 发表于 2025-1-6 21:22:00

PHP文件直接访问也没用啊 没用的

ncsccc 发表于 2025-1-6 21:28:58

[*]location / {
[*]    if (-f $request_filename/index.html){
[*]      rewrite (.*) $1/index.html break;
[*]    }
[*]    if (-f $request_filename/index.php){
[*]      rewrite (.*) $1/index.php;
[*]    }
[*]    if (!-f $request_filename){
[*]      rewrite (.*) /index.php;
[*]    }
[*]    try_files $uri $uri/ /api.php;
[*]}
[*]location /admin {
[*]    try_files $uri /admin/index.php?$args;
[*]}复制代码


我的

httpd 发表于 2025-1-6 21:29:12


ncsccc 发表于 2025-1-6 21:29

我的
是V3.20.20嗎

httpd 发表于 2025-1-6 21:33:44


NodeLoc 发表于 2025-1-6 21:28

PHP文件直接访问也没用啊 没用的
哦哦

ncsccc 发表于 2025-1-6 21:29:00


httpd 发表于 2025-1-6 21:33

是V3.20.20嗎
是的

httpd 发表于 2025-1-6 21:35:12


ncsccc 发表于 2025-1-6 21:36

是的
好簡潔
http://1
页: [1]
查看完整版本: CHEVERETO在Nginx環境的Nginx虛擬主機中有一段僞靜態無法添加