Lighttpd proxy names?

I am trying to configure lighttpd for proxy traffic to one relative path to one proxy server and traffic to another path to another proxy server.

For instance:

http://mydomain.com/ proxies to 123.111.111.1
http://mydomain.com/apathname/ proxies to 123.111.111.2

I flumoxed trying to figure out how to configure / apathname /. This is an example of what I have configured so far, which directs all traffic to 123.111.111.1

$HTTP["host"] =~ "mydomain.com" {

    proxy.balance = "fair"

    proxy.server = ( 
        "" =>
            (
                ("host" => "123.111.111.1", "port" => "80" )
            ),

        "apathname" =>
            (
                ( "host" => "123.111.111.2", "port" => "80" )
            )
    )

}

My apologies if this question should be on another SO site. I am primarily an encoder, not a guy on the network, and I know that I always get the best answers on CA, so I ask here.

+3
source share
1 answer

You need to check the request URL from $HTTP["url"]and configure several proxy rules, for example:

$HTTP["host"] =~ "(www.example.com)" {
    server.document-root = "/var/www/www.example.com"

    $HTTP["url"] =~ "^/upload(.*)$" {
        proxy.server  = ("" => (
            ("host" => "10.2.2.1", "port" => 3000)
        ))
    }

    $HTTP["url"] =~ "^/submit(.*)$" {
        proxy.server  = ("" => (
            ("host" => "10.2.2.2", "port" => 3000)
        ))
    }
}

In this example above:

  • /upload 10.2.2.1:3000.
  • /submit 10.2.2.2:3000.
+5

Source: https://habr.com/ru/post/1795949/


All Articles