我试图在 nginx 反向代理后面保留一个 jenkins 容器(docker)。它适用于此路径https://example.com/但当我向路径https://example.com/jenkins添加参数时它返回 502 Bad Gateway 。
jenkins 的 docker 容器像这样运行 docker container run -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;
}
}