Lighttpd Reverse Proxy Settings

I am trying to configure Lighttpd as a reverse proxy. I want to have several URLs that are proxied on different servers on different ports, either on the same computer or on the local network.

For instance:

// static / connector / ajax

Lighttpd will proxy all connections except those specified in /static. I want to serve all requests /staticdirectly from this lighttpd instance.

Here is the configuration 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 sure my regular expressions are wrong. I also think the line elseis incorrect. I just don't know how to do this. I am new to this area, so I would appreciate some pushing in the right direction.

Thank,

+5
1

, else .

, , /ajax, /ajax/ ( ). URL- ?

+2

All Articles