Thursday, October 14, 2010

Hudson and Listen on Localhost only

I have been using Hudson for almost close to 3 years and have seen many many requirements from clients. Have been amazed by what all can be done using Hudson. Just yesterday, had a rather unusual requirement that Hudson was supposed to listen to only localhost. No user from outside the machine that Hudson was installed should be able to access it. A little bit of research, trial and error, and I was able to get this resolved in a few minutes.

So, next time you have this requirement to run Hudson locally and not be able to access from outside this machine, follow this very simple instruction.

In the normal way of starting Hudson, you will be using either your shell or batch file, which has the following command:

java -jar hudson.war --httpPort=7223

Now, when you don't want external access to Hudson other than localhost, start Hudson as follows:

java -jar hudson.war --httpPort=7223 --httpListenAddress=localhost

Try accessing Hudson from the same machine everything works fine:
Now, try accessing Hudson from another machine, in my case a Virtual Machine, you will see something like this:

Exactly what you want, right?
To see all other options you can provide while using Hudson and the default Winstone servlet container, take a look here: