Tomcat – Apache as reverse-proxy for tomcat (running jenkins)

apache-2.2JenkinsPROXYtomcat

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)

Best Answer

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

RewriteEngine on
RedirectMatch ^/(.*)$ http://outsideaddress/$1