nixCraft Linux / UNIX / Shell Scripting Forum

nixCraft

Linux / UNIX Tech Support Forum

Nginx Reverse Proxy Load Balance Configuration For Apache

This is a discussion on Nginx Reverse Proxy Load Balance Configuration For Apache within the Web servers forums, part of the Mastering Servers category; Hai! I've two node running at 192.168.1.10:80 and 192.168.1.11:80. And one public IP x.y.z.y running at 80. I've installed nginx ...


Register free or login to your account to remove all advertisements.

Go Back   nixCraft Linux / UNIX / Shell Scripting Forum > Mastering Servers > Web servers

Linux answers from nixCraft.


Web servers Discussion on Apache, Nginx and Lighttpd HTTP/web server and configuration issues.

Reply

 

Thread Tools Display Modes
  #1 (permalink)  
Old 23rd December 2009, 11:48 PM
raj's Avatar
raj raj is offline
Senior Member
 
Join Date: Jun 2005
Location: Hyderabad
OS: Fedora, Debian Linux
Posts: 336
Thanks: 47
Thanked 10 Times in 10 Posts
Rep Power: 7
raj will become famous soon enoughraj will become famous soon enough
Lightbulb Nginx Reverse Proxy Load Balance Configuration For Apache

Hai!

I've two node running at 192.168.1.10:80 and 192.168.1.11:80. And one public IP x.y.z.y running at 80. I've installed nginx on x.y.z.y. How do I load balance traffic between two Apache nodes 192.168.1.10:80 and 192.168.1.11:80. ?

TIA
__________________
Raj
Linux rulz.
I have never turned back in my life ; I shall not do so today.. haha
Reply With Quote
  #2 (permalink)  
Old 23rd December 2009, 11:57 PM
nixcraft's Avatar
Never say die
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash, Perl, Python
Posts: 3,195
Thanks: 13
Thanked 394 Times in 292 Posts
Rep Power: 10
nixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond repute
Default

Try:
Code:
 upstream backend  {
      server 192.168.1.10:80;
      server 192.168.1.11:80;
    }

 server {
      access_log  /var/log/nginx/access.log main;
      error_log   /var/log/nginx/error.log;
      index       index.html;
      limit_conn  gulag 50;
      listen      x.y.z.y:80 default; # public IP here
      root        /usr/local/www/nginx;
      server_name _; 
      # get full domain     
      location / {
        proxy_pass  http://backend;
        proxy_cache            cache;
        proxy_cache_valid      200 24h;
        proxy_cache_use_stale  error timeout invalid_header updating http_500 http_502 http_503 http_504;
        proxy_ignore_headers   Expires Cache-Control;
        proxy_redirect     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;
      }
  }
Refer: NginxHttpUpstreamModule
__________________
Vivek Gite
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Do you run a Linux? Let's face it, you need help!
Cricket & IPL News Blog
Reply With Quote
The Following 2 Users Say Thank You to nixcraft For This Useful Post:
raj (30th December 2009), vamsi (30th December 2009)
  #3 (permalink)  
Old 30th December 2009, 05:36 PM
raj's Avatar
raj raj is offline
Senior Member
 
Join Date: Jun 2005
Location: Hyderabad
OS: Fedora, Debian Linux
Posts: 336
Thanks: 47
Thanked 10 Times in 10 Posts
Rep Power: 7
raj will become famous soon enoughraj will become famous soon enough
Default

problem solved!
__________________
Raj
Linux rulz.
I have never turned back in my life ; I shall not do so today.. haha
Reply With Quote
  #4 (permalink)  
Old 15th April 2010, 06:05 AM
Junior Member
 
Join Date: Apr 2010
OS: Freebsd
Scripting language: Bash and friends
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
notjoe is on a distinguished road
Default

Look good!

I have a question similar to this. I have multiple websites, on multiple private ips. I've grasped the fact i would need to set up multiple upstream directives with unique names such as:

upstream site_a {
server 192.168.1.21;
server 192.168.1.31;
}

upstream site_b {
server 192.168.1.22;
server 192.168.1.32;
}


But i am unsure how to direct the incoming traffic to the proper upstream directive!
Reply With Quote
  #5 (permalink)  
Old 15th April 2010, 12:26 PM
nixcraft's Avatar
Never say die
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash, Perl, Python
Posts: 3,195
Thanks: 13
Thanked 394 Times in 292 Posts
Rep Power: 10
nixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond repute
Default

Code:
upstream site_a {
server 192.168.1.21;
server 192.168.1.31;
}

upstream site_b {
server 192.168.1.22;
server 192.168.1.32;
}

# site_a backend with public IP 5.6.7.8:80
server {
      access_log  /var/log/nginx/access.log main;
      error_log   /var/log/nginx/error.log;
      index       index.html;
      limit_conn  gulag 50;
      listen      5.6.7.8:80 default; # public IP here
      root        /usr/local/www/nginx;
      server_name _; 
      # get full domain     
      location / {
        proxy_pass  http://site_a;
        proxy_cache            cache;
        proxy_cache_valid      200 24h;
        proxy_cache_use_stale  error timeout invalid_header updating http_500 http_502 http_503 http_504;
        proxy_ignore_headers   Expires Cache-Control;
        proxy_redirect     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;
      }
  }

# site_b backend with public IP 1.2.3.4:80
server {
      access_log  /var/log/nginx/access.log main;
      error_log   /var/log/nginx/error.log;
      index       index.html;
      limit_conn  gulag 50;
      listen      1.2.3.4:80 default; # public IP here
      root        /usr/local/www/nginx;
      server_name _; 
      # get full domain     
      location / {
        proxy_pass  http://site_b;
        proxy_cache            cache;
        proxy_cache_valid      200 24h;
        proxy_cache_use_stale  error timeout invalid_header updating http_500 http_502 http_503 http_504;
        proxy_ignore_headers   Expires Cache-Control;
        proxy_redirect     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;
      }
  }
See my guide
__________________
Vivek Gite
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Do you run a Linux? Let's face it, you need help!
Cricket & IPL News Blog
Reply With Quote
Reply

Tags
nginx, nginx load balancer, nginx reverse proxy, nginx reverse proxy configuration


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Migrate this apache rewrite ton nginx jarod Web servers 1 23rd December 2009 11:44 PM
Howto Load Balance Squid Proxy Server Requests sandeepvson Proxy Servers 4 14th December 2009 09:13 AM
Want to implement reverse proxy with apache kumarat9pm Proxy Servers 2 5th December 2009 01:14 AM
Which is best for reverse proxy? kumarat9pm Proxy Servers 3 15th September 2009 03:55 PM
Sending request: Apache as a forward and reverse proxy khudabux Web servers 5 11th September 2009 10:15 AM


All times are GMT +5.5. The time now is 09:03 PM.


Powered by vBulletin® Version 3.8.6 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40