-1

I have a simple nginx site config defined like that:

server {
  listen   8082;
  server_name localhost;
  root   /var/www/server.com/public;



  add_header direct_address $remote_addr;   

  real_ip_header X-Forwarded-For;
  set_real_ip_from 0.0.0.0/0;

  add_header load_balancing_address $remote_addr;   
  ... more stuff here ...

}

the $remote_addr is not set properly and it is showing dom0 address. The address is attached to the response header in 'direct_address' header.

This is is behind a load balancing that is passing this variables:

real_ip_header X-Forwarded-For;
set_real_ip_from 0.0.0.0/0;

When a request comes before through the load balancing, the the correct IP is set [the IP of the client machine] in the 'load_balancing_address' header.

I wonder why when accessing directly the server [without passing first in the load balancing] the dom0 IP address is shown.

  • Is the IP address that shows in $remote_addr the IP address of your load balancer? Does your load balancer add/modify the X-Forwarded-For header? – Ladadadada Jul 10 '13 at 13:01
  • @Ladadadada The addresss shown is the one from the server cotainer [called something like dom0 but not sure about the correct name]. I have the correct IP when accessing from the load balancing. For whatever reason When I access the Server directly [without passing trough the load balancing] then I cannot retrieve the proper IP address – dawez Jul 10 '13 at 13:39
0

Ended up that the problem was some routing issue between dom0 and domU, so nothing to do with nginx.

The domU was showing as the remote address and the dom0

Server provider fixed that, I guess that this is related

I managed to configure NAT on dom0 but this does not work properly. Outgoing traffic from domU is seen with the original domU ip address instead of the dom0 ip address and the requests can't get back to the domU.

I figured out MASQUERADING was not set.

The following rule needs to be set:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

|improve this answer|||||

Not the answer you're looking for? Browse other questions tagged or ask your own question.