I\'m trying to follow the directions here: https://wiki.jenkins-ci.org/display/JENKINS/Running+Jenkins+behind+Apache to set up my Jenkins server to appear at http://myhost/j
This is how I fixed it under Debian Wheezy running Jenkin 1.557
in /etc/default/jenkins , modify the JENKINS_ARGS line by adding "--prefix=$PREFIX"
JENKINS_ARGS=" ..... --prefix=$PREFIX"
Put this into /etc/apache2/other/jenkins.conf:
ProxyPass /jenkins http://localhost:8009/jenkins
ProxyPassReverse /jenkins http://localhost:8009/jenkins
ProxyRequests Off
<Proxy http://localhost:8009/jenkins*>
Order deny,allow
Allow from 127.0.0.1
</Proxy>
Then execute these commands:
sudo defaults write /Library/Preferences/org.jenkins-ci httpPort 8009
sudo defaults write /Library/Preferences/org.jenkins-ci prefix /jenkins
sudo launchctl stop org.jenkins-ci
The last command tells launchd to stop the running instance of Jenkins. And a new one will automatically be started because the launchd has been configured to always keep Jenkins running.
For a Windows installation add the prefix within the <arguments>
tag (jenkins.xml) and restart the service (Powershell Restart-Service jenkins
). E.g.:
<executable>%BASE%\jre\bin\java</executable>
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war" --prefix=/jenkins</arguments>
Paraphrasing from the document you mentioned;
You need to specify the context/prefix of the Jenkins instance, this can be done by modifying the Jenkins configuration as follows; Either, set the context path by modifying the jenkins.xml configuration file and adding --prefix=/jenkins (or similar) to the entry. Or Set the context path when using by adding --prefix=/jenkins to JENKINS_ARGS in /etc/default/jenkins (Ubuntu) or in an appropriate startup file.
So, how to find these things...
The Jenkins.xml file should be in the $JENKINS_HOME directory, I'm not sure if Mac OS has the "updatedb" and "locate " commands, but you could try doing updatedb && locate jenkins.xml
Also, have a look in the startup scripts; /etc/init.d if installed from a package, or add the JENKINS_ARGS to the environment properties for the User running Jenkins (append to ~user/.profile
) or the arguments for the container running Jenkins.
Be aware that if your Jenkins installation (without the prefix
argument) was running under:
http://myserver:8080/ => 200 Jenkins is here
adding --prefix=/ci/dashboard
in the arguments will produce this behaviour:
http://myserver:8080/ => 404
http://myserver:8080/ci/dashboard => 200 Jenkins is now here
Just to provide some recent confirmation of the suggested approaches, on CentOS 7, with Jenkins 1.610, I was able to achieve this by changing jenkinsUrl in jenkins.model.JenkinsLocationConfiguration.xml to the desired one (e.g. http://127.0.0.1:8080/jenkins), adding
JENKINS_ARGS="--prefix=/jenkins"
inside /etc/sysconfig/jenkins, and restarting Jenkins.
FYI the Jenkins installation was made via Puppet, using this Puppet module.
I'm using CentOS7, add JENKINS_ARGS="--prefix=/jenkins"
to /etc/sysconfig/jenkins
and restart Jenkins worked. Then you can visit via ip:8080/jenkins