I am wondering how I send back a HTTP response of 501 (Not Implemented) in Lighttpd web server, when somebody tries to access our api.mydomain.com over non-ssl.
The check we have, but don't see how to actually send back the HTTP response of 501.
$HTTP["host"] =~ "api\.mydomain\.com$" {
$HTTP["scheme"] == "http" {
//// HOW DO WE SEND BACK HTTP RESPONSE 501
}
}
Best Answer
The lighttpd way:
With config file, I only know about 404 errors. To send a "non implemented" response, you may use lighttpd mod Magnet (and install LUA), then:
In the config file:
Note that "/path/to/501.lua" should be readable by lighttpd. Then in the 501.lua file:
Very hard to just send a 501... right ?
The alternative way:
If you already have a dinamic language pluged with fastcgi, etc, you can implement error responses (lets say, 501.php) that does what the .lua script makes:
And use them where needed.