Nginx – Change standalone Jenkins default URL

Jenkinsnginx

Running Jenkins standalone (The WAR file, java -war ./jenkins.war or whatever the command is) listening on a non-standard port. I want to get NGINX to proxy from our HTTPS site /jenkins/ to this standalone.

location /jenkins/ {
    proxy_pass http://axolotl.ecogeek.local:10112/;
}

Problem is, Jenkins still things it's at the root URL so all requests are relative to that, so when accessing /jenkins/ it redirects to /login but it needs to go to /jenkins/login, is there any way, through Jenkins or through NGINX, to change the root URL and get it to play nice?

edit

Connecting to Jenkins on it's normal port I can go to Manage Jenkins->Configure System->Jenkins URL and change that, that fixes the redirection but all the media is being requested from /static/ (Have tried restarting Jenkins)

Best Answer

When you go into the Jenkins control panel, you will see a "Manage Jenkins" link. Somewhere down that page, you'll see "Jenkins URL". Try setting that to example.com/jenkins or whatever scheme you have.

Take a look at:

https://wiki.jenkins-ci.org/display/JENKINS/Running+Hudson+behind+Nginx

So, Jenkins is apparently stupid about some things, and you'll need rewrites.