问题在于
proxy_pass http://127.0.0.1:8080;
您没有在此 proxy_pass 中设置 uri,根据http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass意味着:
If proxy_pass is specified without URI, a request URI is passed to the server in
the same form as sent by a client when processing an original request or the full
normalized request URI is passed when processing the changed URI
换句话说,它会将 /jenkins 传递给您的应用程序
我认为在 proxy_pass 中添加斜杠应该可以,如下所示:
location /jenkins/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:8080/;
}
因为这将是一个带有 uri 的请求,根据上面的链接意味着:
If proxy_pass is specified with URI, when passing a request to the server, part
of a normalized request URI matching the location is replaced by a URI specified
in the directive
如果添加斜线不起作用,则必须在另一端通过配置 jenkins 来更改它以期望 /jenkins/ url