1

I'm on Mac OS X, running Ubuntu in VirtualBox. Mac OS can be accessed in the local network with IP 192.168.0.100 and Ubuntu is 192.168.0.123 (it's using the "Bridged Adapter" option in VirtualBox networking settings).

In the Ubuntu installation I have nginx (port 80) working as a reverse proxy to Apache 2.4 (port 8081). This is working fine, and if I open the browser in Mac OS and point to 192.168.0.123 it opens the files served by Apache, through nginx.

The problem is, even though I have enabled the RPAF module, I'm getting unexpected values for server and remote IP addresses on Apache.

When accessing from a browser in Mac, the values I expect are:

SERVER_ADDR = 192.168.0.123 # Apache server IP, which is the Ubuntu IP
REMOTE_ADDR = 192.168.0.100 # The Mac OS X IP

But, if I set nginx to proxy_pass 192.168.0.123:8081 I get:

SERVER_ADDR = 192.168.0.123
REMOTE_ADDR = 198.168.0.123

Setting proxy_pass 127.0.0.1:8081 gives me the correct remote address (191.168.0.100), but 127.0.0.1 as the server address.

Any ideas on how to get the expected results?

(EDIT) I'm using the default RPAF settings:

<IfModule rpaf_module>
RPAF_Enable             On
RPAF_ProxyIPs           127.0.0.1
RPAF_SetHostName        On
RPAF_SetHTTPS           On
RPAF_SetPort            On
RPAF_ForbidIfNotProxy   Off
</IfModule>

And these settings in nginx:

proxy_set_header X-Real-IP  $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header  X-Server-Address  $server_addr;
proxy_set_header Host $host;
5
  • 1
    How is the RPAF module configured? Can you post that entire configuration file as well?
    – Andy Shinn
    Sep 28, 2014 at 17:58
  • @AndyShinn I added the RPAF settings to the post Sep 28, 2014 at 18:12
  • 1
    @ViniciusPinto - You would need to add 192.168.0.123 to the RPAF_proxyips directive. Sep 28, 2014 at 18:49
  • @VivekThomas Thanks, that worked! Please post as an answer so I can accept it. Sep 28, 2014 at 19:20
  • 1
    Ah, that is what i suspected and why I asked for that information. You beat me to it!
    – Andy Shinn
    Sep 30, 2014 at 2:09

1 Answer 1

3

Apache would see the IP address 192.168.0.123 as the source and that needs to be added the RPAF_proxyips directive, this tells mod_rpaf that its a known proxy.

Quoting from http://www.stderr.net/apache/rpaf/

It changes the remote address of the client visible to other Apache modules when two conditions are satisfied. First condition is that the remote client is actually a proxy that is defined in httpd.conf. Secondly if there is an incoming X-Forwarded-For header and the proxy is in it's list of known proxies it takes the last IP from the incoming X-Forwarded-For header and changes the remote address of the client in the request structure. It also takes the incoming X-Host header and updates the virtualhost settings accordingly. For Apache2 mod_proxy it takes the X-Forwared-Host header and updates the virtualhosts

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .