Running Jenkins with apache at /jenkins

I need to have access at the /jenkins path to the Jenkins server.

This is what I have now in my apache configuration:

ProxyPass /jenkins http://localhost:8080
ProxyPassReverse /jenkins http://localhost:8080

When I go to example.com/jenkins,
I get redirected to example.com/login?from=%2F,
instead of the expected exmaple.com/jenkins/login?from=%2F.

So is it possible with apache to make all the requests coming from my Jenkins server, be of the form example.com/jenkins/* instead of example.com/*?

P.S.: I know it would be a far better practice create a new server, named something like jenkins.example.com, but that’s not an option for me at the moment.

Answer

It looks like there is an option for configuring the Jenkins URL, inside Jenkins itself: Jenkins website root path.

Also, I have found the apache configuration documentation, in the Jenkins Wiki:
Running Jenkins behind Apache.

EDIT:

I managed to achieve running the Jenkins server at http://example.com/jenkins like this:

  • on my local machine, by adding to the JENKINS_ARGS variable, the --prefix=/jenkins attribute, in /etc/default/jenkins file, and then restarting the Jenkins service. (soruce: this answer)
  • on my docker image, by adding --prefix=/jenkins at the end of the run command: docker run --name Jenkins -p 8080:8080 -p 50000:50000 jenkins --prefix=/jenkins

And here is my apache configuration entry for Jenkins:

ProxyPass        /jenkins http://localhost:8080/jenkins nocanon
ProxyPassReverse /jenkins http://localhost:8080/jenkins
ProxyRequests    Off
AllowEncodedSlashes NoDecode

Source: Running Jenkins behind Apache

Attribution
Source : Link , Question Author : DrKaoliN , Answer Author : DrKaoliN

Leave a Comment