skip to Main Content

I ‘ve setup Jenkins server which is running as a docker container behind Nginx reverse proxy, it is served at example.com/jenkins/, everything is working fine except getting "It appears that your reverse proxy set up is broken" error on "manage Jenkins page". I would be grateful if anyone can help.

Docker compose file

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 file


   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/;

        }


2

Answers


  1. Your proxy redirect seems off here as you don’t have to remap /jenkins context. Here is a simple config that worked for me in the past.

    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/;
            }
    }
    
    Login or Signup to reply.
  2. You can simply change the url that is in Manage jenkins > Configure system to the new url you are using , for your case it is example.com/jenkins/, that should make the error go away.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search