获取您的反向代理设置似乎在Jenkins上被破坏了

bhmjp9jg  于 2023-05-16  发布在  Jenkins
关注(0)|答案(1)|浏览(193)

我已经设置了Jenkins服务器,它作为Nginx反向代理后面的Docker容器运行,它在example. com/jenkins/提供服务,一切都很好,除了在“管理Jenkins页面”上得到“看起来你的反向代理设置被破坏了”错误。如果有人能帮忙,我将不胜感激。

Docker合成文件

version: "3.4"

services:
  jenkins:
    image: jenkins/jenkins:lts
    container_name: jenkins
    environment:
      JENKINS_OPTS: "--prefix=/jenkins"
    ports:
      - 9292:8080
      - 50000:50000
    volumes:
      - ./data:/var/jenkins_home
      - /var/run/docker.sock:/var/run/docker.sock

Nginx conf文件

location /jenkins/ {

        proxy_set_header    Host                $host:$server_port;
        proxy_set_header    X-Real-IP           $remote_addr;
        proxy_set_header    X-Forwarded-Host    $host:$server_port;
        proxy_set_header    X-Forwarded-Server  $host:$server_port;
        proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto   $scheme;
        proxy_pass      http://localhost:9292;
        proxy_redirect  http://localhost:9292/ /jenkins/;

        }
lo8azlld

lo8azlld1#

您的代理重定向在这里似乎关闭,因为您不必重新Map/jenkins上下文。这里有一个简单的配置,在过去为我工作。

server {
    listen 80;
    server_name jenkins.ycr.com;

    location /jenkins {
            proxy_pass  http://127.0.0.1:8080;
            proxy_redirect http://127.0.0.1:8080/ http://jenkins.ycr.com/;
        }
}

相关问题