nginx problem with allow when forwarding through 2 proxy's

Tomasz Pajor nikon at
Fri Dec 19 13:40:15 MSK 2008

i think we misunderstood each other, nginx2 conf:

location / {
  set $my_host maintenance.my_domain;
  if ($remote_addr ~ ip.address) { set $my_host $host; }
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header Host $my_host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

based on $remote_addr i show proper page or just maintenance page for 
users when I need to, but now when I have another nginx (nginx1) in 
front of nginx2 this won't work, because nginx2 sees $remote_addr as the 
address of nginx1

same goes for allow directive, wont work on nginx2
>> Schema:
>> nginx1 -> nginx2 -> apache
>> On nginx2 i've got stub status module, and I want to allow only one ip  
>> to view the data.
>> But when I add the directive, it won't work, because nginx2 sees that  
>> connection came from nginx1 which is on the same machine as nginx2 so  
>> client ip would be
>> Is that a bug or it should be that way?
> Maxim Dounin

More information about the nginx mailing list