I have set up apache to work as a reverse proxy to tomcat that is running jenkins-CI. I can access the site from outside fine, except when I log in to jenkins, it redirects to my lan-hostname, and it of course it fails outside my network. After that I can manually type the original address to the browser, and it it will work fine until I have to log in again.

I wonder if this is a problem in jenkins, or in my apache/tomcat proxy setup.

Jenkins also reports on the management page that my proxy setup is not right, but does not tell any more.

Apache VirtualHost configuration:

<VirtualHost *:80>
    ServerName jenkins.outsideaddress
    ServerAlias ci.outsideaddress jenkins.insideaddress ci.insideaddress
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/

Also the proxy, and proxy_http modules are loaded (according to apachectl -M)

  • I still haven't been able to get it to work... – Esa Varemo Jan 8 '13 at 10:40

Try to add this after ProxyPassReverse. outsideaddress is your outside FQDN.

RewriteEngine on
RedirectMatch ^/(.*)$ http://outsideaddress/$1
  • I tried it, but it didnt have any effect... – Esa Varemo Sep 22 '12 at 20:10
  • Well actually when I now try it on a computer outside of my LAN, it goes to the right domain, but still can't show the page... For example: "Internet explorer can't show the page outsideaddress/j_acegi_security_check" after I log in. If I remove the part after the domain, it has logged in and show me the dashboard – Esa Varemo Sep 24 '12 at 8:17

In Jenkins, look in "Manage Jenkins" and then scroll down to the "Jenkins URL" field. Change that to jenkins.outsideaddress.

For inside access, set up your LAN DNS to resolve jenkins.outsideaddress to jenkins.insideaddress, either through a renaming or via CNAME. You can also set up a catchall on the internal addresses that will redirect to jenkins.outsideaddress.

  • I suspected it might be something like that. Thanks! EDIT: Actually it already points to the outside-address... Also the login is the only place where this happens – Esa Varemo Sep 19 '12 at 14:26
  • Hmm. Are you doing the login under SSL, so that you're hitting a different virtual host? – cjc Sep 19 '12 at 14:33
  • I have not configured it to be under SSL, and I have no vhosts to respond to it, all are on port 80. – Esa Varemo Sep 19 '12 at 14:35

I was finally able to fix the problem (at least I think so)!

I ran into a similar issue when trying to configure the nexus maven repository to work nicely under a similar apache httpd proxy configuration. Then I happened to ran into an issue submited to their issue tracker, where it constructed some URL's wrongly.

In the comments a suggested fix was to add

ProxyPreserveHost On

to the virtual host in httpd's conf where the other proxy configuration directives are. I no longer see the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.