Nginx not reverse proxying correctly

Hello,

I come seeking your help because I have a problem that I have been
unable to
solve using the classic Internet resources.

Currently, we have an Apache2 webserver acting as load balancer for our
web
architecture. The backends are Xen virtual machines accessible via IPv6
for
the public Internet and via IPv4 for our VPN. The problem is that the
Apache
2 loadbalancer doesn’t perform as well as we would like it to so we’re
switching to nginx.

The version of nginx installed is 1.3.10 which was compiled with
standard
Debian options. We had to go for this version because it was the only
one
that supports IPv6 backends which is a requirement for these VMs. For
the
moment, nginx only has one “virtual host” or server block and it is the
following.

upstream backend-cookissime-prod  {
  server cookissime-prod.cookissime1.vm.cob:80 max_fails=5;
  server cookissime-prod.cookissime2.vm.cob:80 max_fails=5;
}

server {
  listen 37.59.6.220:80;
#  listen [::]:80;
  server_name www.cookissime.fr;

  access_log  /var/log/nginx/cookissime-prod.log;
  error_log  /var/log/nginx/cookissime-prod.log;

  ## send request back to apache1 ##
  location / {
    proxy_pass  http://backend-cookissime-prod;
    proxy_next_upstream error timeout invalid_header http_500 

http_502
http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
}
}

There is also a second code block which takes the above information and
replaces prod with dev. The domain names
cookissime-prod.cookissime1.vm.cob
and cookissime-prod.cookissime2.vm.cob resolve to an IPv6 on our
internal
DNS.

The above configuration seems to be good syntax-wise. The problem is
that
most of the time, this configuration displays the default “Welcome to
nginx”
page but sporadically it will display the website for a few minutes then
return to the default page.

This very setup works correctly with Apache2 so the virtual machines are
functionnal.

What am I missing ? What could cause these problems ?

Thank you in advance for your help,

Antoine Benkemoun

Posted at Nginx Forum: