Linux / UNIX Tech Support Forum
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.
|
|||||||
| Web servers Discussion on Apache, Nginx and Lighttpd HTTP/web server and configuration issues. |
![]() |
|
|
Thread Tools | Display Modes |
|
||||
|
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;
}
}
__________________
Vivek Gite |
|
|||
|
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! |
|
||||
|
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;
}
}
__________________
Vivek Gite |
![]() |
|
|
| 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 | |
|
|
|
||||
| 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 |