Listening Ports on HTTPd

I recently had a web server behind a load balancer that needed to listen on a different port because the load balancer was translating port 80 traffic for security. Thankfully, changing the ports that HTTPd listens on is relatively simple.

Crack open your favorite command line editor. For the purposes of this example, I'll be using vim.

vim /etc/httpd/conf/httpd.conf

This is a relatively large file, so you'll have to scroll for some time to find what we're looking for. Otherwise, you can use search. Scroll down until you find a section that looks like Listen 80
 * 1) Listen: Allows you to bind Apache to specific IP addresses and/or
 * 2) ports, in addition to the default. See also the 
 * 3) directive.
 * 4) Change this to Listen on specific IP addresses as shown below to
 * 5) prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
 * 6) Listen 12.34.56.78:80
 * 1) prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
 * 2) Listen 12.34.56.78:80
 * 1) Listen 12.34.56.78:80

Depending on your needs, whatever ports you need, add "Listen " in this section. If for instance you need httpd to listen for an ssl (https) encrypted connection, you can add Listen 443

Once you've made the changes you want, save and close the file and run the command /etc/init.d/httpd restart

That's all there is to it! Now for lunch.