立即注册  找回密码
 立即注册
CeraNetworksBGVM服务器主机交流会员请立即修改密码Sharktech防护
查看: 64|回复: 8

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

[复制链接]

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

[复制链接]

471

主题

396

回帖

3031

积分

论坛元老

积分
3031
httpd

471

主题

396

回帖

3031

积分

论坛元老

积分
3031
2025-1-6 21:20:36 | 显示全部楼层 |阅读模式
[ol]
  • # 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;
  •     }[/ol]复制代码

    就是這一段中的
    [ol]
  •     # 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;
  •     }[/ol]复制代码
    這段添加進去Nginx報錯,無法啓動
  • 回复

    使用道具 举报

    341

    主题

    844

    回帖

    3411

    积分

    论坛元老

    积分
    3411
    NodeLoc

    341

    主题

    844

    回帖

    3411

    积分

    论坛元老

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

    使用道具 举报

    471

    主题

    396

    回帖

    3031

    积分

    论坛元老

    积分
    3031
    httpd 楼主

    471

    主题

    396

    回帖

    3031

    积分

    论坛元老

    积分
    3031
    2025-1-6 21:24:03 | 显示全部楼层

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

    删掉就好了 这一段没用

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

    使用道具 举报

    341

    主题

    844

    回帖

    3411

    积分

    论坛元老

    积分
    3411
    NodeLoc

    341

    主题

    844

    回帖

    3411

    积分

    论坛元老

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

    使用道具 举报

    6

    主题

    26

    回帖

    106

    积分

    注册会员

    积分
    106
    ncsccc

    6

    主题

    26

    回帖

    106

    积分

    注册会员

    积分
    106
    2025-1-6 21:28:58 | 显示全部楼层
    [ol]
  • 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;
  • }[/ol]复制代码


    我的
  • 回复

    使用道具 举报

    471

    主题

    396

    回帖

    3031

    积分

    论坛元老

    积分
    3031
    httpd 楼主

    471

    主题

    396

    回帖

    3031

    积分

    论坛元老

    积分
    3031
    2025-1-6 21:29:12 | 显示全部楼层

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

    我的

    是V3.20.20嗎
    回复

    使用道具 举报

    471

    主题

    396

    回帖

    3031

    积分

    论坛元老

    积分
    3031
    httpd 楼主

    471

    主题

    396

    回帖

    3031

    积分

    论坛元老

    积分
    3031
    2025-1-6 21:33:44 | 显示全部楼层

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

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

    哦哦
    回复

    使用道具 举报

    6

    主题

    26

    回帖

    106

    积分

    注册会员

    积分
    106
    ncsccc

    6

    主题

    26

    回帖

    106

    积分

    注册会员

    积分
    106
    2025-1-6 21:29:00 | 显示全部楼层

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

    是V3.20.20嗎

    是的
    回复

    使用道具 举报

    471

    主题

    396

    回帖

    3031

    积分

    论坛元老

    积分
    3031
    httpd 楼主

    471

    主题

    396

    回帖

    3031

    积分

    论坛元老

    积分
    3031
    2025-1-6 21:35:12 | 显示全部楼层
    回复

    使用道具 举报

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

    本版积分规则

    Archiver|小黑屋|HS2V主机综合交流论坛

    GMT+8, 2025-5-14 15:05 , Processed in 0.022891 second(s), 2 queries , Gzip On, Redis On.

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

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