Make Jenkins use a subdomain without 8080 port behind apache2

Jenkins

I’m failing at redirecting my Jenkins to use my subdomain (build.core-network.us) and not require :8080 port slapped behind it.

I’m on Debian Wheezy.

I use Apache (proxy and proxy_http are installed) and this is my /etc/apache2/sites-available/build.core-network.us file:

<VirtualHost *:80>
  ServerName  build.core-network.us:80
  ServerAlias www.build.core-network.us
  ServerAdmin piotr@riddle.pl

  ProxyPass         /  http://localhost:8080/
  ProxyPassReverse  /  http://localhost:8080/
  ProxyRequests     Off

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

</VirtualHost>

I made sure that /etc/default/jenkins has --httpListenAddress=127.0.0.1 --httpPort=8080 as JENKINS_ARGS

And of course build.core-network.us has correct DNS entry (and it works fine when I add :8080 port to it).

I found 4 other posts like this with 4 different VirtualHost recommendations and either they’re not for me or I’m failing to use them properly.

Update 1: I found errors in error.log:

[Fri Sep 26 17:33:59 2014] [notice] SIGUSR1 received.  Doing graceful restart
[Fri Sep 26 17:33:59 2014] [notice] Apache/2.2.22 (Debian) configured -- resuming normal operations
[Fri Sep 26 17:33:59 2014] [error] proxy: ap_get_scoreboard_lb(0) failed in child 11990 for worker proxy:reverse
[Fri Sep 26 17:33:59 2014] [error] proxy: ap_get_scoreboard_lb(0) failed in child 11991 for worker proxy:reverse

Update 2: I did sudo /etc/init.d/apache2 stop and then start, didn’t help.

Best Answer

I believe the error is here:

 ServerName  build.core-network.us:80

Drop the :80, that's not part of the Host: header. What's happening is that this isn't matching your request, and your system is falling through to another virtualhost (the first one loaded, if nothing explicitly matches).

www.build.core-network.us should be working now, which you can also use to test.


Also, you don't need the <Proxy> section, that is only for forward proxy.

In most cases ProxyRequests is off already, so that's probably redundant, but doesn't hurt.