Nginx 服务器块未正确重定向

Nginx 服务器块未正确重定向

我最近刚刚从 apache2 切换到 nginx,它似乎处理加载时间要好得多。但是,我现在无法访问我的论坛子域。每当我转到论坛的子域时,它都会将我重定向到我的站点的根目录。我已启用该站点并链接到 sites-available 目录。这是我当前的服务器块:

  server {
    listen 80;
    server_name forum.project-freedom.net;
    root /var/www/forum;

    index index.html index.htm index.php;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.0-fpm.sock;
    }
 }

我的主要网站目录是 /var/www/html/

检查我的 nginx 错误日志后,我发现出现了这个错误:

2023/04/16 05:26:20 [error] 45598#45598: *65 open() "/var/www/html/service_worker.js" failed (2: No such file or directory), client: 172.70.34.128, server: _, request: "GET /service_worker.js HTTP/2.0", host: "forum.project-freedom.net">
2023/04/16 05:35:07 [error] 45598#45598: *257 open() "/var/www/html/service_worker.js" failed (2: No such file or directory), client: 172.70.135.196, server: _, request: "GET /service_worker.js HTTP/2.0", host: "forum.project-freedom.ne>
2023/04/16 05:35:37 [error] 45598#45598: *258 "/var/www/html/project-freedom.net/index.php" is not found (2: No such file or directory), client: 162.158.78.139, server: _, request: "GET /project-freedom.net/ HTTP/2.0", host: "project-fr>
2023/04/16 05:42:20 [error] 45598#45598: *416 open() "/var/www/html/service_worker.js" failed (2: No such file or directory), client: 172.70.38.15, server: _, request: "GET /service_worker.js HTTP/2.0", host: "forum.project-freedom.net">
2023/04/16 05:42:32 [notice] 46586#46586: signal process started
<dom.net", referrer: "https://forum.project-freedom.net/service_worker.js"

相关内容