Since Nginx appeared, we all like to let Nginx run in front of the processing of static files, and then through proxy to the dynamic request filtering to Apache.
So there is a problem, running in the rear Apache application to obtain the IP is the nginx server IP, or the local 127.0.0.1.
The most obvious is to view Apache's access logs. You will see the IP of the intranet.
If your app has something like, "Single IP cannot log on repeatedly", "Single IP registration is n minutes apart" ... Security rules for IP discrimination.
So much trouble ....
But fortunately, you can modify the parameters of the Nginx proxy so that the backend application obtains the request message from Nginx to obtain the IP of the extranet.
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
But this solves the problem only in the application, the Apache log to obtain the IP is still local.
Search, found Apache this one from a third-party mod with Nginx proxy use.
Description: http://stderr.net/apache/rpaf/
Download: http://stderr.net/apache/rpaf/download/
The latest version is mod_rpaf-0.6.tar.gz
Installation is also fairly straightforward.
# tar zxvf mod_rpaf-0.6.tar.gz Download and unzip
# CD mod_rpaf-0.6
The Apache directory is modified according to its own environment, and the appropriate installation method is selected:
#/usr/local/apache/bin/apxs-i-a-c MOD_RPAF.C Apache 1.3.x installation method
#/usr/local/apache/bin/apxs-i-c-n mod_rpaf-2.0.so mod_rpaf-2.0.c Apache 2.x installation method
You'll be added a line in the LoadModule area of http.conf when you're done.
LoadModule Mod_rpaf-2.0.so_module modules/mod_rpaf-2.0.so
Apache 2.2.6 Experiment, the use of this line to launch Apache will be an error.
So instead:
LoadModule Rpaf_module modules/mod_rpaf-2.0.so
and add it below
Rpafenable on
Rpafsethostname on
Rpafproxy_ips 127.0.0.1 192.168.10.2 # Fill in the intranet IP where Nginx resides.
Rpafheader x-forwarded-for
Restart Apache after saving exit
And look at Apache's log content? Oh, it's no longer the IP that came and went.
Reprinted from Http://blog.sina.com.cn/s/blog_4560b80b0100m79m.html
Apache and Apache in a coexistence environment to obtain the real IP