Nginx 和 Jenkins 配置

问题描述 投票:0回答:1

我有 2 个虚拟机(VM1 和 VM2),想要构建以下基础架构:

  • VM1 将作为入口点,我需要安装 Jenkins 和 Nginx。 Jenkins 仅适用于 CI/CD 管道,nginx 充当反向代理和负载均衡器。
  • VM2 Tomcat 作为 Java 应用程序的应用服务器

我在访问 Jenkins 时遇到问题

我做了以下配置:

Nginx

server {
    listen 80;
    server_name VM1_IP;

    location /jenkins {
        proxy_pass http://localhost:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

詹金斯

JENKINS_ARGS="--webroot=.... --httpPort=$HTTP_PORT --prefix=/jenkins"

詹金斯网址

http://VM1_IP/jenkins

由于某种原因,我无法访问 Jenkins,理论上,Jenkins 应该可以通过

http://VM1_IP/jenkins
访问,但它会将我重定向到登录名,并返回 404 :(

我做错了什么?

nginx jenkins reverse-proxy
1个回答
0
投票

尝试添加

proxy_redirect
指令来替换任何重定向标头。

location /jenkins {
      proxy_pass  http://127.0.0.1:8080;
      proxy_redirect http://127.0.0.1:8080/ http://VM1_IP/;
}
© www.soinside.com 2019 - 2024. All rights reserved.