Conditional Lighttpd Configuration Based on Request Headers

Is it possible to conditionally configure Lighttpd based on custom request headers?

This can be done by IP address (and other variables):

$HTTP["remoteip"] ==  "0.0.0.0" {
    // Do something
}

Is there something similar for request headers, for example:

$HTTP["X-Some-Header"] ==  "Value" {
    // Do something
}

I don’t think that the documentation and search in Google is being looked through, but maybe someone knows a way.

thank

+5
source share
2 answers

After a larger search, I'm pretty sure this is not possible.

For me, the solution was to change my application.

+2
source

You can do this with Lighttpd starting from version 1.4.6, see https://redmine.lighttpd.net/projects/1/wiki/docs_configuration

In my case, it looks something like this:

$REQUEST_HEADER["Content-Type"] == "application/rdf+xml" { 
    url.redirect = ( "^/somewhere/(.*)$" => "/somewhere-else" ) 
}
0

All Articles