ip based access behind nginx load balancer
Reinis Rozitis
r at roze.lv
Fri Jun 11 21:01:12 MSD 2010
You are allready pasing them back to your backend servers with:
proxy_set_header X-Real-IP $remote_addr;
The thing you need now is that the backend webservers use this as the real
clients IP.
For Apache you can use mod_rpaf http://stderr.net/apache/rpaf/ ( just
change the RPAFheader to X-Real-IP obviosly).
For nginx you use the RealIp module (
http://wiki.nginx.org/NginxHttpRealIpModule )
For IIS I am not sure (as I dont use it) but quick googling gave something
like this http://www.winfrasoft.com/X-Forwarded-For.htm
rr
--------------------------------------------------
From: "ahlatci" <nginx-forum at nginx.us>
Sent: Friday, June 11, 2010 6:05 PM
To: <nginx at nginx.org>
Subject: ip based access behind nginx load balancer
> I'm sure this has been asked before, but I could not find an answer.I'm
> using nginx-0.7.66.I have 6 webservers running Apache, tomcat, IIS on it.
> We are using ip base access for some directories and files on our
> servers.But when we use nginx as a load balancer, these rules (ip based
> access on apache,tomcat and IIS) are not working , because of our servers
> are seeing Nginx's ip address as client ip address.
>
> Does anybody know how I can pass client's ip addresses directly through
> our servers on Nginx?
>
> here is our sample nginx.conf
> #########################
>
> #user nobody;
> worker_processes 16;
>
> error_log logs/error.log;
> pid logs/nginx.pid;
>
>
> events {
> worker_connections 1024;
> }
>
> upstream webserver_a {
> ip_hash;
> server 192.168.100.4:80;
> server 192.168.100.5:80;
> }
>
> server {
> listen *:80;
> server_name our.domain.com;
> access_log logs/webserver_a.access.log;
>
>
> location / {
>
> proxy_set_header X-Real-IP $remote_addr;
> # needed for HTTPS
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_set_header Host $http_host;
> proxy_redirect off;
> proxy_max_temp_file_size 0;
>
> proxy_pass http://webserser_a;
> } # location
> } # server
> } # http
>
> Posted at Nginx Forum:
> http://forum.nginx.org/read.php?2,97154,97154#msg-97154
>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx
>
More information about the nginx
mailing list