Nginx + Glassfish breaks HTTP Headers?

I tried the following combinations

  1. Nginx + Mongrel (MRI)
  2. Nginx + Mongrel (Jruby)
  3. Nginx + Glassfish Gem
  4. Glassfish Gem

Basically for 1), 2) and 3) I use Nginx to service static files and
Mongrel/Glassfish to service rails with the following config

     proxy_set_header   Host             $host;
     proxy_set_header   X-Real-IP        $remote_addr;
     proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

With 1), 2) and 4) everything works fine,

However things start to break when I do 3) which is putting Nginx in
front of Glassfish Gem.

There appears to be some redundant stuffing of HTTP Headers, which
breaks all Ajax requests. The regular HTTP Get request work fine though.

But, when I remove Nginx to access Glassfish directly, then things are
fine.

At this point, 3) is my preferred deployment because Glassfish appears
to not suffer from the memory leak that Mongrel (Jruby) does, and I need
Nginx to service all other requests on this machine.

Sharkie L. wrote:

I tried the following combinations

  1. Nginx + Mongrel (MRI)
  2. Nginx + Mongrel (Jruby)
  3. Nginx + Glassfish Gem
  4. Glassfish Gem

I get Transfer-Encoding: chunked when in (3) and (4).

(1) and (2) I don’t that that Transfer-Encoding?

Could that be causing the problem?