Project

General

Profile

Actions

Bug #1706

closed

mod_proxy not sending a response for post requests

Added by Anonymous over 15 years ago. Updated almost 8 years ago.

Status:
Fixed
Priority:
Normal
Category:
mod_proxy
Target version:
ASK QUESTIONS IN Forums:

Description

I have setup lighttpd with mod_proxy to redirect requests to /msg/* to 127.0.0.1:8888/msg/* which works fine for GET requests.
When sending a post request the client gets no response from the server (the request is send to the backend-server, but the response is not passed through)

config:


server.modules   += ( "mod_proxy" )
proxy.debug = 1
proxy.balance     = "fair" 
$HTTP["host"] == "im.xxx.de" {
$HTTP["url"] =~ "^/msg/" {
proxy.server     = ( "" =>
                     (
                       ( "host" => "127.0.0.1",
                         "port" => 8888
                       )
                     )
                    )
}
}

strace:


09:59:31.948819 read(7, "POST /msg/setStatus HTTP/1.1\r\nHost: im.xxx.de\r\nUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9) Gecko/2008052906 Firefox/3.0\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-gb,en;q=0.5\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\nKeep-Alive: 300\r\nConnection: keep-alive\r\nContent-Type: application/x-www-form-urlencoded; charset=UTF-8\r\nContent-Length: 8\r\nCookie: xxx\r\nPragma: no-cache\r\nCache-Control: no-cache\r\n\r\ntst=test", 895) = 758
09:59:31.949309 stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2295, ...}) = 0
09:59:31.949496 write(5, "2008-07-02 09:59:31: (mod_proxy.c.1079) proxy - start \n", 55) = 55
09:59:31.949656 write(5, "2008-07-02 09:59:31: (mod_proxy.c.1115) proxy - ext found \n", 59) = 59
09:59:31.949795 write(5, "2008-07-02 09:59:31: (mod_proxy.c.1158) proxy - used fair balancing \n", 69) = 69
09:59:31.949969 write(5, "2008-07-02 09:59:31: (mod_proxy.c.1239) proxy - found a host 127.0.0.1 8888 \n", 83) = 83
09:59:31.950128 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 8
09:59:31.950244 fcntl64(8, F_SETFD, FD_CLOEXEC) = 0
09:59:31.950350 fcntl64(8, F_SETFL, O_RDWR|O_NONBLOCK) = 0
09:59:31.950463 connect(8, {sa_family=AF_INET, sin_port=htons(8888), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
09:59:31.950652 write(5, "2008-07-02 09:59:31: (mod_proxy.c.377) connect delayed: 8 \n", 59) = 59
09:59:31.950761 time(NULL)              = 1214985571
09:59:31.950837 poll([{fd=4, events=POLLIN}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=9, events=POLLIN}, {fd=-1}, {fd=8, events=POLLOUT, revents=POLLOUT}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}], 30, 1000) = 1
09:59:31.951025 write(5, "2008-07-02 09:59:31: (mod_proxy.c.993) proxy: fdevent-out 1 \n", 61) = 61
09:59:31.951138 getsockopt(8, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
09:59:31.951211 write(5, "2008-07-02 09:59:31: (mod_proxy.c.804) proxy - connect - delayed success \n", 74) = 74
09:59:31.951380 writev(8, [{"POST /msg/setStatus HTTP/1.0\r\nHost: im.xxx.de\r\nUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9) Gecko/2008052906 Firefox/3.0\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-gb,en;q=0.5\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\nKeep-Alive: 300\r\nContent-Type: application/x-www-form-urlencoded; charset=UTF-8\r\nContent-Length: 8\r\nCookie: xxx\r\nPragma: no-cache\r\nCache-Control: no-cache\r\nX-Forwarded-For: xxx.xxx.xxx.xxx\r\nX-Host: im.xxx.de\r\nX-Forwarded-Proto: http\r\n\r\n", 808}, {"tst=test", 8}], 2) = 816
09:59:31.951790 time(NULL)              = 1214985571
09:59:31.951860 poll([{fd=4, events=POLLIN}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=9, events=POLLIN}, {fd=-1}, {fd=8, events=POLLIN, revents=POLLIN}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}], 30, 1000) = 1
09:59:31.952996 write(5, "2008-07-02 09:59:31: (mod_proxy.c.960) proxy: fdevent-in 4 \n", 60) = 60
09:59:31.953111 ioctl(8, FIONREAD, [194]) = 0

09:59:31.953188 write(5, "2008-07-02 09:59:31: (mod_proxy.c.645) proxy - have to read: 194 \n", 66) = 66
09:59:31.953291 read(8, "HTTP/1.1 401 Unauthorized\r\nCache-control: no-cache\r\nContent-type: text/x-json; charset=utf-8\r\nExpires: Fri, 30 Oct 1998 14:19:41 GMT\r\nContent-length: 0\r\nConnection: close\r\nServer: Apache/2.0\r\n\r\n", 194) = 194

Nothing more after that...

-- lighttpd

Actions #1

Updated by Anonymous over 15 years ago

Sorry, wrong version, its 1.4.13


root@im /etc/lighttpd/conf-enabled $ lighttpd -v
lighttpd-1.4.13 (ssl) - a light and fast webserver
Build-Date: Apr 15 2008 08:23:10
Actions #2

Updated by gstrauss about 8 years ago

(old ticket, but still some ideas, though I hope Anonymous is no longer having this problem)

lighttpd mod_proxy is reverse proxy speaking the HTTP/1.0 specification. mod_proxy is implemented to finish reading response when it reads 0-bytes from socket, which occurs after the backend shuts down its write end of the socket, or closes the socket. Even though the proxy response in the trace above includes Content-Length: 0, lighttpd mod_proxy still waits for the backend to indicate "done" by shutting down or closing the connection.

What is the your backend? Does it shutdown(fd, SHUT_WR) or close() the connection after sending its response (including Connection: close shown in trace)? Your trace ends without showing any further socket fd events, such as if mod_proxy read 0 bytes from backend.

Actions #3

Updated by stbuehler about 8 years ago

  • Description updated (diff)
  • Assignee deleted (jan)
  • Target version set to 1.4.x

sounds like a broken backend. mod_proxy could do better too of course.

Actions #4

Updated by gstrauss about 8 years ago

  • Status changed from New to Fixed

Same issue as https://redmine.lighttpd.net/issues/1943

Should be fixed in next version of lighttpd (1.4.40)
Patch available at https://github.com/lighttpd/lighttpd1.4/pull/39 has been committed to trunk.

Actions #5

Updated by gstrauss almost 8 years ago

  • Target version changed from 1.4.x to 1.4.40
Actions

Also available in: Atom