lighttpd does not send a 301 redirect immediately when proxying to Apache
I am using lighttpd as a proxy to an Apache backend. In MediaWiki if a 301 is issued, the redirect takes 15 seconds to complete. This is because by default Apache's KeepAlive timeout is 15 seconds; so lighttpd waits for the connection to be closed, when it should send the redirect to the client right away.
If I lower the keep alive of Apache, then it takes that number of seconds for the redirect to come to the client (eg, setting the keep alive timeout to 5 seconds makes the redirect take 5 seconds), so the problem is clearly that lighttpd waits until the connection is closed.
A redirect taking 15 seconds is of course problematic.
Note that with a 302, this behavior does not happen.
Tested under vanilla-1.4.28.
#1 Updated by stbuehler over 5 years ago
Ok, i can reproduce it:
Run a "webserver" to generate 301 responses:
while true; do (echo -en 'HTTP/1.1 301 Moved Permanently\r\nLocation: XYZ\r\nContent-Length: 0\r\n\r\n'; cat) | nc -4 -v -l localhost 8080; echo Connection closed; done
(Press CTRL-D to close an accepted connection)
proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => 8080 ) ) )
#2 Updated by nitrox over 5 years ago
- Priority changed from High to Normal
Don´t use "High" if it isn´t a severe bug!
Normaly a Status: 301 + Location headers would be all thats needed. Though a manual link in the body section is for users whose browsers do not support this feature. So we need to wait for the body part.
#10 Updated by stbuehler about 2 years ago
- Target version changed from 1.4.34 to 1.4.x
todo: close (backend) connection after response body was received, use content-length header
but: shouldn't be needed with HTTP/1.0 connections (which is all that mod_proxy supports) - probably in this case not directly apache's fault but some backend sending connection: keep-alive.
(sane) patches welcome.
Also available in: Atom