I am trying to configure Lighttpd to act as a reverse proxy. I want to have several URLs that are proxied to different servers on different ports, either on the same machine or within the local network.
For example:
/ /static /socket /ajax
Lighttpd would proxy all of the connections except those to /static
. I want to serve all requests to /static
directly from this instance of lighttpd.
Here is the config file for mod_proxy:
##
# Serve Static Content via Lighttpd.
#
$HTTP["url"] =~ "^/static/" {
server.document-root = "/path/to/my/static/files"
accesslog.filename = rootdir + "/var/log/static.log"
server.errorlog = rootdir + "/var/log/static.error.log"
}
##
# Proxy to instance of Socket.io.
#
else $HTTP["url"] =~ "^/socket/" {
accesslog.filename = rootdir + "/var/log/socket.log"
server.errorlog = rootdir + "/var/log/socket.error.log"
proxy.server = (
"" => ( (
"host" => "127.0.0.1",
"port" => 3000
) )
)
}
##
# Proxy to AJAX backend.
#
else $HTTP["url"] =~ "^/ajax/" {
accesslog.filename = rootdir + "/var/log/ajax.log"
server.errorlog = rootdir + "/var/log/ajax.error.log"
proxy.server = (
"" => ( (
"host" => "127.0.0.1",
"port" => 4000
) )
)
}
##
# Proxy to something that returns my layout.
#
else $HTTP["url"] =~ "^/" {
accesslog.filename = rootdir + "/var/log/root.log"
server.errorlog = rootdir + "/var/log/root.error.log"
proxy.server = (
"" => ( (
"host" => "127.0.0.1",
"port" => 5000
) )
)
}
I am pretty sure that my regular expressions are wrong. I also think the else
stringing is wrong. I am just not sure how else to do it. I am new to this area, so I would appreciate some nudges in the right direction.
Thanks,