How to use nginx as loadbalancer for different webserver?

Jörg Kastning joerg.kastning at synaxon.de
Sun Apr 21 06:29:58 UTC 2013


Hello all.

I'm new to this maillinglist as to nginx as well. I setup a nginx to run as
a loadbalancer with just adding the following lines to my
/etc/nginx/nginx_conf. This config works fine.

http {
  upstream loadbalancer1 {
    server 192.168.0.1:80;
    server 192.168.0.2:80;
  }

  server {
    listen 80;
    server_name www.example.com example.com;
    location / {
      proxy_pass http://loadbalancer1;
    }
  }

Please note, that example.com isn't my real domain. So that's not the error. ;-)

Now I tried to add a second site which is hosted on two different
webservers. My configuration in /etc/nginx/nginx_conf looks like the
following now.

http {
  upstream loadbalancer1 {
    server 192.168.0.1:80;
    server 192.168.0.2:80;
  }

  server {
    listen 80;
    server_name www.example.com example.com;
    location / {
      proxy_pass http://loadbalancer1;
    }
  }

upstream loadbalancer2 {
    server 192.168.0.3:80;
    server 192.168.0.4:80;
  }

  server {
    listen 80;
    server_name www.anyway.com anyway.com;
    location / {
      proxy_pass http://loadbalancer2;
    }
  }}

But if I try to get www.anyway.com it didn't work and I got a request
timeout. Could somebody please tell me, what's wrong with my
configuration?


Best Regards

Joerg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20130421/65b1f294/attachment.html>


More information about the nginx mailing list