librelist archives

« back to archive

[Mongrel2] The cooperation problem between mongrel2 and nginx?

[Mongrel2] The cooperation problem between mongrel2 and nginx?

From:
Tang Daogang
Date:
2011-05-09 @ 09:33
hi,

I met a problem on the cooperation problem between mongrel2 and nginx.

When the browser make a request to nginx, the backend handler (tir) can get
the full req object, but browser can't receive the response from nginx?

I have checked that the handler worked very well. And if I visit the
http://myurl:6767 directly, browser can receive right data.

Maybe the problem is on the cooperation between mongrel2 and nginx?

And my nginx config is:

server {
        listen  80;
        client_max_body_size 100M;
        server_name  xxxxx.com www.xxxxx.com;

        access_log  /var/log/nginx/tfzhw.access.log;

                location / {
                        proxy_pass http://myip:6767;
                        proxy_redirect off;
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
        }

}

Any help? Thank you.

-- 
Nothing is impossible.

Re: [mongrel2] [Mongrel2] The cooperation problem between mongrel2 and nginx?

From:
Zed A. Shaw
Date:
2011-05-15 @ 06:34
On Mon, May 09, 2011 at 05:33:13PM +0800, Tang Daogang wrote:
> hi,
> 
> I met a problem on the cooperation problem between mongrel2 and nginx.

Sorry I missed this.

> When the browser make a request to nginx, the backend handler (tir) can get
> the full req object, but browser can't receive the response from nginx?
> 
> I have checked that the handler worked very well. And if I visit the
> http://myurl:6767 directly, browser can receive right data.
> 
> Maybe the problem is on the cooperation between mongrel2 and nginx?

That's possible, it might be that nginx expects HTTP 1.1 style
semantics so wants the connection always closed.  Try having Tir send a
close after each response to see if that does it.

Let me know, and also look at Wireshark to debug the protocol if you
can't see it easily.

-- 
Zed A. Shaw
http://zedshaw.com/

Re: [mongrel2] [Mongrel2] The cooperation problem between mongrel2 and nginx?

From:
Tang Daogang
Date:
2011-05-15 @ 09:03
On Sun, May 15, 2011 at 2:34 PM, Zed A. Shaw <zedshaw@zedshaw.com> wrote:

> On Mon, May 09, 2011 at 05:33:13PM +0800, Tang Daogang wrote:
> > hi,
> >
> > I met a problem on the cooperation problem between mongrel2 and nginx.
>
> Sorry I missed this.
>
> > When the browser make a request to nginx, the backend handler (tir) can
> get
> > the full req object, but browser can't receive the response from nginx?
> >
> > I have checked that the handler worked very well. And if I visit the
> > http://myurl:6767 directly, browser can receive right data.
> >
> > Maybe the problem is on the cooperation between mongrel2 and nginx?
>
> That's possible, it might be that nginx expects HTTP 1.1 style
> semantics so wants the connection always closed.  Try having Tir send a
> close after each response to see if that does it.
>
> Oh, that's true.  I have add self:close() in end of the reply_http()
funcion and now, that problem disappers.

Great. Thx.



> Let me know, and also look at Wireshark to debug the protocol if you
> can't see it easily.
>
> --
> Zed A. Shaw
> http://zedshaw.com/
>



-- 
Nothing is impossible.

Re: [mongrel2] [Mongrel2] The cooperation problem between mongrel2 and nginx?

From:
Zed A. Shaw
Date:
2011-05-15 @ 15:33
On Sun, May 15, 2011 at 05:03:07PM +0800, Tang Daogang wrote:
> > That's possible, it might be that nginx expects HTTP 1.1 style
> > semantics so wants the connection always closed.  Try having Tir send a
> > close after each response to see if that does it.
> >
> > Oh, that's true.  I have add self:close() in end of the reply_http()
> funcion and now, that problem disappers.
> 
> Great. Thx.

Ok, I'll look at adding a feature where you can specify that be done to
all requests.

http://tir.mongrel2.org/tktview/f899cf601ddfa5f48dc03842236fc7dc129568f5

-- 
Zed A. Shaw
http://zedshaw.com/