2

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.

thecoshman
  • 221
  • 1
  • 2
  • 6
  • From the Jenkins management screen, did you properly set the Jenkins URL? – cerberus Feb 28 '17 at 13:44
  • @cerberus Yes, the Jenkins URL is set correctly – thecoshman Feb 28 '17 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 May 11 '18 at 09: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 May 11 '18 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 May 12 '18 at 12:46
  • @lievendp so it appears that this may have simply been a hard fault in Jenkins itself? If you managed to get this to work in Apache, then it should be possible in Nginx. Could you maybe post an answer with a bit more detail on what you did, I still use Jenkins and I'm sure I'll hit this similar problem again at some point. Thanks – thecoshman May 14 '18 at 12:07
  • basically, what I copied from the wiki page of jenkins (https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Apache) – lievendp May 24 '18 at 13:08
  • ProxyPass /jenkins http://localhost:8081/jenkins nocanon ProxyPassReverse /jenkins http://localhost:8081/jenkins ProxyPassReverse /jenkins http://your.host.com/jenkins – lievendp May 24 '18 at 13:08

0 Answers0