jenkins背后nginx反向代理

我试图让一个jenkins容器(docker)在nginx反向代理的后面。 对于https://example.com/这个path,它可以正常工作,但是当我将参数添加到pathhttps://example.com/jenkins时,它会返回502 Bad Gateway。

jenkins的docker容器像这个docker容器运行-d -p 127.0.0.1:8080:8080 jenkins / jenkins

这是我的代码,

server { listen 80; root /var/www/html; server_name schoolcloudy.com www.schoolcloudy.com; location / { proxy_pass http://localhost:8000; } } # Virtual Host configuration for example.com upstream jenkins { server 127.0.0.1:8080; } server { listen 80; server_name jenkins; location /jenkins { proxy_pass http://jenkins; proxy_redirect 127.0.0.1:8080 https://schoolcloudy.com/jenkins; } } 

运行容器时,使用--network=host标志指定Jenkins容器的networking。 这样容器将能够与主机networking交互或者在Nginx conf中明确使用容器的IP。