Make lighttpd listen on multiple ports

scubbo picture scubbo · Jan 15, 2013 · Viewed 17.5k times · Source

I have a lighttpd server running on an AWS EC2 instance. It can serve on port 80 (or any other port, if I change server.port in /etc/lighttpd/lighttpd.conf) with no problems. However, when I serve an alternative document-root on a different port (say, 8080), browsers can never connect to the server.

The relevant section of my lighttpd.conf file:

server.port = 80

##
## Use IPv6?
##
server.use-ipv6 = "disable"

##
## bind to a specific IP
##
#server.bind = "localhost"

##
## Run as a different username/groupname.
## This requires root permissions during startup. 
##
server.username  = "lighttpd"
server.groupname = "lighttpd"

## 
## enable core files.
##
#server.core-files = "disable"

##
## Document root
##
server.document-root = server_root + "/release"
$SERVER["socket"] == ":8080" {
        server.document-root = server_root + "/dev"
}

Full file here

The site rooted at server_root + "/dev" works fine - I have tested by reversing their port assignations, in which case /dev loads fine on :80 and /release is not found.

I've read numerous guides (e.g. here, official docs, here, etc.), to no avail. The first of these mentioned that there might be a firewall conflict, but I don't know how to resolve that on EC2, and the fact that I can set server.port=8080 with no problem makes me think this is not the issue.

Both folders are owned by my lighttpd user, which has full rights in both folders.

I don't see anything of note in log files when making a request to <my address>:8080.

Answer

scubbo picture scubbo · Jan 16, 2013

Whoops, I can now answer my own question.

It was, indeed, a firewall issue, but it was very simple to fix - go to console.aws.amazon.com (log in if necessary), select the relevant security group, and add a firewall rule allowing incoming traffic on that port - either from a particular source if you wish to restrict access, or from 0.0.0.0/0 for universal access.