-1

I need to send all CGI request to another server so I decided to use it with proxy. The problem is that I need to send the client IP to the server so I did the following configuration:

$HTTP["url"] =~ "cgi" {
    $HTTP["remoteip"] =~ "^(.*)$" {
        url.rewrite-once = ("^(.*)$" => "$1?myip=%1")
    }

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

the problem is that its not rewriting the URL.

1 Answers1

0

Found: can't use rewrite inside a $HTTP["url"] comparation. the url condition must be inside the rewrite, like the configuration below

$HTTP["remoteip"] =~ "^(.*)$" {
    url.rewrite-once = ("^(.*cgi.*)$" => "$1?myip=%1")
}

$HTTP["url"] =~ "cgi" {
proxy.server     = (
                "" =>
             (
               ( "host" => "XXX.XXX.XXX.XXX",
                 "port" => 80,
               )
             )
            )
}