Re: Rails' 302 redirect is being converted to 502

From: Alexey Kovyrin <alexey#kovyrin.net>
Date: Tue, 7 Oct 2008 00:02:22 -0400


Ah, and one more thing. When I look in the logs for this particular request I see the following:

127.0.0.1:44934 [06/Oct/2008:21:44:12.170] scribd.com scribd.com/mongrel01 0/0/0/-1/10 502 820 - - SH-- 0/0/0/0/0 0/0 "GET /word/document_url/6417541 HTTP/1.0"

Btw, nginx/lighttpd/apache reverse proxy features work like a charm for this URL...

On Mon, Oct 6, 2008 at 11:53 PM, Alexey Kovyrin <alexey#kovyrin.net> wrote:
> Hello,
>
> We've hit a problem here with haproxy->mongrels pool configuration.
> One of really many calls to a rails action which returns pretty
> standard 302 redirect is being converted to a 502 response. It works
> for many different urls and fails on one particular URL.
>
> Rails ver: 2.0.2
> Mongrel version: 1.1.5
> HA-Proxy version 1.3.15.4 2008/09/14
> Copyright 2000-2008 Willy Tarreau <w#1wt.eu>
>
> Build options :
> TARGET = linux26
> CPU = generic
> CC = gcc
> CFLAGS = -O2 -g
> OPTIONS = USE_PCRE=1
>
>
> Haproxy config:
>
> global
> log 127.0.0.1 daemon debug
> ulimit-n 32768
> pidfile /var/run/haproxy.pid
> maxconn 8000
> uid apache
> gid apache
> daemon
>
> defaults
> log global
> mode http
> option httplog
> option abortonclose
> retries 5
> maxconn 8000
> contimeout 3000000
> clitimeout 1500000
> srvtimeout 3000000
> redispatch
> mode http
> balance roundrobin
>
> listen loops.scribd.com 127.0.0.1:8080
> server mongrel00 127.0.0.1:8000 maxconn 1 check
> server mongrel01 127.0.0.1:8001 maxconn 1 check
> server mongrel02 127.0.0.1:8002 maxconn 1 check
> server mongrel03 127.0.0.1:8003 maxconn 1 check
>
>
>
> Direct request to the rails action:
> root@loops:/opt/haproxy# curl http://127.0.0.1:8000/word/document_url/6417541 -v
> * About to connect() to 127.0.0.1 port 8000 (#0)
> * Trying 127.0.0.1... connected
> * Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0)
>> GET /word/document_url/6417541 HTTP/1.1
>> User-Agent: curl/7.16.4 (i486-pc-linux-gnu) libcurl/7.16.4 OpenSSL/0.9.8e zlib/1.2.3.3 libidn/1.0
>> Host: 127.0.0.1:8000
>> Accept: */*
>>
> < HTTP/1.1 302 Moved Temporarily
> < Connection: close
> < Date: Tue, 07 Oct 2008 03:51:43 GMT
> < Set-Cookie: _scribd_session=BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%250ASGFzaHsABjoKQHVzZWR7AA%253D%253D--f04a5432060febfe36092a7e2b74525af0d4a01b;
> domain=.scribd.com; path=/; expires=Sun, 01 Jan 2017 06:00:00 GMT
> < Status: 302 Found
> < Location: http://www.market-research-report.com/Merchant2/merchant.mvc?Store_Code=analysis&AFFIL=scribd2121&Screen=PROD&Product_Code=imtc0264
> < X-Runtime: 0.01000
> < Cache-Control: no-cache
> < Server: Mongrel 1.1.5
> < Content-Type: text/html; charset=utf-8
> < Content-Length: 0
> <
> * Closing connection #0
>
>
>
>
> Haproxy request:
> root@loops:/opt/haproxy# curl http://127.0.0.1:8080/word/document_url/6417541 -v
> * About to connect() to 127.0.0.1 port 8080 (#0)
> * Trying 127.0.0.1... connected
> * Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
>> GET /word/document_url/6417541 HTTP/1.1
>> User-Agent: curl/7.16.4 (i486-pc-linux-gnu) libcurl/7.16.4 OpenSSL/0.9.8e zlib/1.2.3.3 libidn/1.0
>> Host: 127.0.0.1:8080
>> Accept: */*
>>
> * HTTP 1.0, assume close after body
> < HTTP/1.0 502 Bad Gateway
> < Cache-Control: no-cache
> < Connection: close
> < Content-Type: text/html
> <
> <html><body><h1>502 Bad Gateway</h1>
> The server returned an invalid or incomplete response.
> </body></html>
> * Closing connection #0
>
>
>
>
> Debug output from haproxy:
> 00000002:scribd.com.accept(0007)=0008 from [127.0.0.1:35163]
> 00000002:scribd.com.clireq[0008:ffff]: GET /word/document_url/6417541 HTTP/1.1
> 00000002:scribd.com.clihdr[0008:ffff]: User-Agent: curl/7.16.4
> (i486-pc-linux-gnu) libcurl/7.16.4 OpenSSL/0.9.8e zlib/1.2.3.3
> libidn/1.0
> 00000002:scribd.com.clihdr[0008:ffff]: Host: 127.0.0.1:8080
> 00000002:scribd.com.clihdr[0008:ffff]: Accept: */*
> 00000002:scribd.com.srvrep[0008:0009]: HTTP/1.1 302 Moved Temporarily
> 00000002:scribd.com.srvhdr[0008:0009]: Connection: close
> 00000002:scribd.com.srvhdr[0008:0009]: Date: Tue, 07 Oct 2008 03:52:01 GMT
> 00000002:scribd.com.srvhdr[0008:0009]: Set-Cookie:
> _scribd_session=BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%250ASGFzaHsABjoKQHVzZWR7AA%253D%253D--f04a5432060febfe36092a7e2b74525af0d4a01b;
> domain=.scribd.com; path=/; expires=Sun, 01 Jan 2017 06:00:00 GMT
> 00000002:scribd.com.srvhdr[0008:0009]: Status: 302 Found
> 00000002:scribd.com.srvcls[0008:0009]
> 00000002:scribd.com.srvcls[0008:0009]
> 00000002:scribd.com.srvcls[0008:0009]
> 00000002:scribd.com.clicls[0008:0009]
> 00000002:scribd.com.srvcls[0008:0009]
> 00000002:scribd.com.closed[0008:0009]
>
>
> Please advise on possible solutions/workarounds/etc.
>
> Thanks in advance.
>
> --
> Alexey Kovyrin
> http://kovyrin.info/
>

-- 
Alexey Kovyrin
http://kovyrin.info/
Received on 2008/10/07 06:02

This archive was generated by hypermail 2.2.0 : 2008/10/07 06:16 CEST