My server is running Ubuntu 8.4 Hardy, but the instructions are relatively generic.
Installing Hudson deb package
The Hudson package is not in the default repositories, but that wouldn't be too useful anyway as it would be hard to keep up with the frequent Hudson releases.
Installation instructions for installing the deb package, or see the wiki page for more discussion.
By default the hudson deb package will install hudson in /var/lib/hudson, which also contains a config.xml with some options. Command line options can be found in /etc/default/hudson. The hudson log is in /var/log/hudson/hudson.log. You may want to run
tail -f /var/log/hudson/hudson.log
while debugging the installation.
You can start Hudson with:
sudo /etc/init.d/hudson start
Hudson should now be running on port 8080 of your machine.
Remember to register a user and set up access control if you are running the machine on the public internet.
If needed, you can stop Hudson with:
sudo /etc/init.d/hudson stop
Hudson on port 80
To set up Hudson to run on port 80 (the normal http port) instead of 8080 you could edit /etc/default/hudson and add --httpPort=80 to HUDSON_ARGS. However, running a service on any port below 1024 requires the service to be run as root on Linux, which is not such a good idea for a compex Java application. If you try to start hudson with the --httpPort=80 argument in /etc/default/hudson, you'll get a "java.net.BindException: Permission denied" exception in the log.
It appears the standard procedure is to run apache (or another webserver), and configure it to hand over processing of a certain path to Hudson. Mod_proxy seems to be the way to go.
Hudson Prefix
We want to see hudson running on servername/hudson/. The first step is to change the prefix hudson uses, so we get from servername:8080/ to servername:8080/hudson/. To do that, add
--prefix=/hudson
to the HUDSON_ARGS string in /etc/default/hudson and restart Hudson with e.g.:
sudo /etc/init.d/hudson force-reload
Apache
If you don't have apache installed, use
sudo apt-get install apache2
to install it.
mod_proxy
In many distributions it should be included by default with apache, but you may need to install the mod_proxy module separately:
sudo apt-get install libapache2-mod-proxy-html
In any case you need to enable it with:
sudo a2enmod proxy
sudo a2enmod proxy_http
By default it is configured to deny all proxying, so edit /etc/apache2/mods enabled/proxy.conf to allow proxying:
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
[Note that messing up proxy configuration could leave your server as an open proxy, so proceed at your own risk. I'm just copy pasting code from documentation without fully understanding it...]
In your /etc/apache2/sites-enabled/ directory there should be some file like 000-default or similar, with settings for the site. Add proxy configurations in it for mapping the /hudson path on the website to localhost:8080/hudson:
ProxyPass /hudson http://127.0.0.1:8080/hudson
You can of course use some other path than /hudson too, in that case remember to also use it with the Hudson --prefix parameter above.
In my case the file looks something like:
<VirtualHost *>
</VirtualHost>
You can stop and restart apache to enable the new configuration, or just use:
/etc/init.d/apache2 force-reload
And you can follow the apache logs for troubleshooting by running
tail -f /var/log/apache2/error.log
Good luck, and feel free to suggest improvements to this configuration in the comments.
Hi,
There is no /etc/default/hudson file neither HUDSON_ARGS in /etc/init.d/hudson.
How can we do now?
Regards, Charlie
Charlie
10:42 PMwhy use mod_proxy - mod_ajp avoids the need to use hudson's built in web server at all.
Anonymous
12:38 AMSometimes Hudson tries to redirect user (the simplest example is redirection from /hudson to /hudson/?). In such cases Apache does not translate the URL Hudson redirects to, and end user ends up redirected to 127.0.0.1/hudson/?, which, considering that there are other redirects, is not acceptable.
Maybe there is some way to configure Apache so that it would request from Hudson the original URL without changing it to 127.0.0.1/... ?
rotsor
7:45 AMOK, I solved it by making Apache translate redirect URLs like this:
ProxyPass /hudson http://127.0.0.1:8080/hudson
rotsor
7:53 AMI mean like this:
ProxyPassReverse /hudson http://127.0.0.1:8080/hudson
rotsor
7:54 AMTry in /etc/sysconfig/hudson for adding the param.
Anonymous
10:32 AMThanks for the info. This blog post was really helpful in getting me going.
After reloading the apache2 server, I was seeing a lot of errors like this in /var/log/apache2/error.log:
[Sat Feb 19 12:48:45 2011] [error] proxy: ap_get_scoreboard_lb(0) failed in child 6401 for worker http://localhost:8088/hudson
I found an online post saying that apache sometimes has problems when reloading the config when going from mod_proxy not being installed to mod_proxy being installed.
Stopping and starting apache2 with "/etc/init.d/apache2 stop" and restarting it with "/etc/init.d/apache2 start" got rid of the error messages.
Bill Dieter
7:59 PMI've struggled to get it from the root to the directory. Thanks for the instructions. Finally get it working.
Egor
9:53 AM