3
votes

I have jenkins running inside tomcat on my server:

http://davez0r.com:8080/jenkins

I'd like apache to point a subdomain to this instead:

http://ci.davez0r.com

There are directions for doing this:

So I set up the subdomain with my provider and then added a virtual host in httpd.conf:

<VirtualHost *:80>
    ServerName        ci.davez0r.com
    ProxyPass         /  http://localhost:8080/jenkins
    ProxyPassReverse  /  http://localhost:8080/jenkins
    ProxyRequests     Off

    <Proxy http://localhost:8080/jenkins*>
        Order deny,allow
        Allow from all
    </Proxy>
</VirtualHost>

This is below my other virtual host entry that I'm using to rewrite my mediawiki URLs.

I then restarted everything.

The problem is that now when I go to the desired URL, I get redirected to:

http://ci.davez0r.com/jenkins

At which point I'm presented with a blank page.

I don't know who's even doing the redirecting. Is it Jenkins, Apache, Tomcat...?

Versions:

  • RHEL 6.2
  • Apache 2.2.15
  • Coyote 1.1
2

2 Answers

2
votes

This works for me:

<VirtualHost *:80>
    ServerName        ci.davez0r.com
    ProxyPass         /  http://localhost:8080/jenkins/
    ProxyPassReverse  /  http://localhost:8080/jenkins/
    ProxyRequests     Off
    ProxyPreserveHost On
    <Proxy http://localhost:8080/jenkins/*>
        Order deny,allow
        Allow from all
    </Proxy>
    RewriteEngine on
    RewriteRule   ^/jenkins/(.+) http://%{HTTP_HOST}/$1
</VirtualHost>

Adding a trailing slash after the Proxy URL resulted in an infinite loop. Then adding trailing slashes after the ProxyPass URLs made it work, but all the static content had the wrong URLs.

So I added a rewrite rule to remove the extra /jenkins/ directory that was showing up who knows why.

0
votes

Tomcat is generating the redirect to what - as far as it is concerned - is the correct URL.

There are a couple of options. By far the simplest is to deploy Jenkins as the ROOT web application on Tomcat.

The trickier option is to figure out how the redirect is being passed back and add the appropriate configuration in httpd to change it. To fix all the issues you are likely to see you'll probably need some combination of mod_headers and mod_substitute.