无法将上游与 nginx 服务器中的文件夹映射

Cha*_*ngh 3 nginx winginx nginx-location

我想将我们的系统端口 82 映射到 127.0.0.1:8080/runningSite 并且我遇到了 nginx 配置异常。

upstream dev {
    server 127.0.0.1:8080/runningSite;
}
server {
    rewrite_log on;
    listen [::]:81;
    server_name localhost;

    location / {
        proxy_pass  http://dev;
        proxy_set_header Host $http_host;
    }

}
Run Code Online (Sandbox Code Playgroud)

例外 :

nginx: [emerg] invalid host in upstream "127.0.0.1:8080/runningSite" in C:\nginx -1.8.1/conf/nginx.conf:85
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助我哪里我错了。

Ric*_*ith 5

您的 URI 位于错误的位置。它需要进入proxy_pass而不是在upstream块中。

尝试这个:

upstream dev {
    server 127.0.0.1:8080;
}
server {
    rewrite_log on;
    listen [::]:81;
    server_name localhost;

    location / {
        proxy_pass  http://dev/runningSite/;
        proxy_set_header  Host $http_host;          
    }
}
Run Code Online (Sandbox Code Playgroud)

有关详细信息,请参阅此文档