NGINX位置给出404错误,即使目录存在

我已经这样设置了NGINX配置文件

root /var/www/html/tests_manager/webroot;

    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm index.nginx-debian.html;
    server_name qa.kloc.co.uk; # managed by Certbot

    location / {
            # First attempt to serve request as file,then
            # as directory,then fall back to displaying a 404.
            rewrite ^/uploads/(.*) /uploads/uploadsController.php last;
            try_files $uri $uri/ =404;
    }

    location /support {
        root /var/www/html/support-manager/webroot; #I have checked,this directory exists.
    }

    location = /notifications {
        proxy_pass http://localhost:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }

    location = /supportsocket {
        proxy_pass http://localhost:8081;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;

            # With php7.0-cgi alone:
            #fastcgi_pass 127.0.0.1:9000;
            # With php7.0-fpm:
            fastcgi_pass unix:/run/php/php7.3-fpm.sock;
    }

我希望/support位置重定向到另一个根目录,以便用户尝试访问qa.kloc.co.uk/support时,他们可以在目录/var/www/html/support-manager/webroot中看到该站点

我的问题是,每当尝试浏览该URL时,我只会收到404错误。我检查了访问日志,但它们没有帮助。我只是看到

GET /support/index.php HTTP/1.1" 404 209

错误日志中没有任何内容。

我尝试使用重写(例如/ uploads /),但我认为我无法转义根目录。我也尝试使用location = /supportlocation ^~ /support,但它们没有任何作用。

我还尝试过将/var/www/html/support-manager/webroot/目录的所有者更改为www-data,但这没有什么不同。

请帮助我以正确的方式编写/ support位置

landaming 回答:NGINX位置给出404错误,即使目录存在

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3123161.html

大家都在问