Link to home
Create AccountLog in
Avatar of virtualjim
virtualjimFlag for Slovenia

asked on

nginx proxy load balance

i have a ubuntu 10.04 with nginx /0.8.54 running as a load balance proxy
named: www.local.com

I have two IIS backend servers which responds on Host header request
web1.local.com
web2.local.com

now when i hit my nginx balancer on www.local.com my backend servers dont (they respond with the defalt IP webpage {empy} )respond since they are waiting for a right host header (e.g. web1.local.com)

my nginx.conf
upstream backend {
                server web1.local.com:80;
                server web2.local.com:80;
        }
        server {
          listen 80;
                location / {
                  proxy_pass  http://backend;
                  proxy_set_header        X-Real-IP       $remote_addr;
                  proxy_set_header        Host            $proxy_host;
                }
        }



any hint ?
Avatar of ToxicPig
ToxicPig
Flag of United States of America image

As the load balancer is simply forwarding a request for www.local.com, then your backend servers need to have VirtualHosts set up to respond to that address.  Accomplish this via a ServerAlias directive (or even set the ServerName itself) within your Apache config.
Oh, IIS, sorry.  On your Web Site Properties dialog, under Web Site, hit the Advanced dialog and add Host Headers (aliases) that the site should respond to.  Put www.local.com here.
Avatar of virtualjim

ASKER

my IIS web servers are responding isung web1 and web2

The thing is that ngix x as a proxy load balancer does not send http post headers right
ASKER CERTIFIED SOLUTION
Avatar of ToxicPig
ToxicPig
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
What header is it sending?
ToxicPig

do you know how nginx works?

the
proxy_set_header        Host            $_host;

Open in new window


Should work..but it does not

Right, which is why I would like to know EXACTLY what it IS sending.  Trace a header please.
hi!

So from my local pc if i hit web1.local.com it responds
if i hit web1.local.com from nginx using lynx it responds

but when i try to hit www.local.com from my pc or from nginx i always get the default webpage

how can i trace a header ?

thanks