3

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/
</VirtualHost>

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

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

3 Answers 3

3

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

RewriteEngine on
RedirectMatch ^/(.*)$ http://outsideaddress/$1
2
  • I tried it, but it didnt have any effect...
    – Esa Varemo
    Commented Sep 22, 2012 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
    Commented Sep 24, 2012 at 8:17
1

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.

3
  • 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
    Commented Sep 19, 2012 at 14:26
  • Hmm. Are you doing the login under SSL, so that you're hitting a different virtual host?
    – cjc
    Commented Sep 19, 2012 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
    Commented Sep 19, 2012 at 14:35
1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .