How to use nginx as loadbalancer for different webserver?

Steve Holdoway steve at greengecko.co.nz
Sun Apr 21 06:39:16 UTC 2013


Try telnetting to port 80 on 192.168.0.3 and .4 to check they're
listening, and that www.anyway.com resolves correctly...


On Sun, 2013-04-21 at 08:29 +0200, Jörg Kastning wrote:
> 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
> 
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

-- 
Steve Holdoway BSc(Hons) MIITP 
http://www.greengecko.co.nz
Skype: sholdowa



More information about the nginx mailing list