3

I have a pair of servers, one running Nginx the other Jenkins (well, and other servers for other services, but that's besides the point). These servers sit within their own subnet that normally would not be accessible from my machine. For testing purposes, these two machines both have an ip that I can access from my machine.

If I access the Jenkins server directly, everything works as I would expect. More or less a standard Jenkins installation, done so via centos package. Only slight minor modifications was using nginx on to redirect from 80 to 8080 and also having jenkins listen to /jenkins rather than just /; this was done via updating the config of jenkins to include --prefix=/jenkins.

However, the idea is that these servers are only accessible through the nginx server, as this will at some point be the https endpoint, but for now, it's just http. I have setup the reverse proxy on the nginx server and it almost works perfectly. The only issue now is that when I log in or out, whilst it does work, I get taken to the wrong ip and nothing loads in my browser. ie;

  • I am on <nginx ip>:80/jenkins
  • I click log in
  • It attempts to take me to <jenkins ip on wrong subnet>:80/jenkins
  • I refresh and <nginx ip>:80/jenkins loads with me logged in
  • I hover over the log out button, link says <nginx ip>:80/jenkins/logout
  • I click log out
  • It attempts to take me to <jenkins ip on wrong subnet>:80/jenkins/logout
  • I refresh page, and I am logged out

I can't work out why Jenkins is using this subnet ip specifically for the log in/out. I believe jenkins is using it's own tomcat instance, but I can't seem to find any installation of it on this machine. Other services that I have set up via reverse proxy have either connected or not.

8
  • From the Jenkins management screen, did you properly set the Jenkins URL?
    – cerberus
    Commented Feb 28, 2017 at 13:44
  • @cerberus Yes, the Jenkins URL is set correctly
    – thecoshman
    Commented Feb 28, 2017 at 15:06
  • Hi, did you ever manage to fix this as I'm currently experiencing the same issue in "monolith" type setup. Before clicking the button it clearly shows being on https and going to https but when I actually do the login I have the "http://" (instead of https) in my url which obviously fails. Similarly, when requesting parameters for an executed job, it fails putting "http" in the url. manually fixing to "https" and refresh and it works fine.
    – lievendp
    Commented May 11, 2018 at 9:47
  • @lievendp Oh man, I'm not sure to be honest, the setup evolved a bit over time. I think I did eventually manage to resolve this though. I don't know how similar your issue will be though to be honest. This was only an issue for log in/out. Best of luck
    – thecoshman
    Commented May 11, 2018 at 11:49
  • @thcoshman thanks for replying, managed to solve using apache instead of nginx and forcing the reverse proxy to go back around passing through https as described on the "behind proxy" wiki page for jenkins. Turns out jenkins in that version returned url's that became http even with the proxypassreverse for whatever reason. A newer version of jenkins lts in docker didn't appear to have this "problem". KR.
    – lievendp
    Commented May 12, 2018 at 12:46

0

You must log in to answer this question.

Browse other questions tagged .