skip to Main Content

I have 2 VMs (VM1 and VM2), and want to build the following infrastructure:

  • VM1 will be an entry point, and I need to install Jenkins and Nginx. Jenkins is just for CI/CD pipelines, and nginx acts as a reverse proxy and load balancer.
  • VM2 Tomcat as the application server for Java applications

I have a problem with access to the Jenkins

I made the following config:

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

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

Jenkins URL

http://VM1_IP/jenkins

For some reason I’m not able to access Jenkins, in theory, Jenkins should be accessible at http://VM1_IP/jenkins, but it redirects me to the login, and returns 404 🙁

What did I do wrong?

2

Answers


  1. Try adding proxy_redirect directive to replace any redirect headers.

    location /jenkins {
          proxy_pass  http://127.0.0.1:8080;
          proxy_redirect http://127.0.0.1:8080/ http://VM1_IP/;
    }
    
    Login or Signup to reply.
  2. Include this configuration –>

          proxy_pass  http://127.0.0.1:8080;
          proxy_redirect http://127.0.0.1:8080/ http://VM1_IP/;
    }
    
    

    Within

            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;
        }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search