2

I currently have a proxy.server rule in lighttpd.conf that forwards all requests of routemsg.pl to port 1530:

$HTTP["url"] =~ "/routemsg.pl" {
    proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => 1528) ) )
}

How can I change the rule to allow the requester to pass a port param in the URL and that param be then used as the port to proxy the request to?

For example: A request of: http://www.myip.com/routemsg.pl?p=1531 would go to 127.0.0.1 on port 1531.

4

1 回答 1

2

You could try using $HTTP["querystring"] and capture the port with a conditional like this:

$HTTP["url"] =~ "/routemsg.pl" {
    $HTTP["querystring"] =~ "p=([0-9]+)" {
        proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => "%1") ) )
    }
}

I sadly don't have a setup on which I can confirm that it works right now, I'm afraid. :(

于 2011-11-29T06:30:05.687 回答