The issue with the wrong IP address being shown when using nginx as reverse proxy can easily be solved with mod_rpaf.
vs
cache.blog.tuinslak.org 85.12.6.171 – – [22/May/2010:16:27:40 +0200] “GET /2010/05/nginx-reverse-proxy/ HTTP/1.0” 200 22639 “-” “Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.53 Safari/533.4” 1771 23031
First one being my current home IP address, the second one being the nginx server IP address. The idea is to have the first line to show up in the logs.
On Gentoo (and I guess it’s fairly similar on other distributions);
* www-apache/mod_rpaf Latest version available: 0.6 Latest version installed: 0.6 Size of files: 7 kB Homepage: http://stderr.net/apache/rpaf/ Description: Reverse proxy add forward module License: Apache-2.0
Emerge it, add “-D RPAF” to /etc/conf.d/apache2 and add the following the the correct vhost (e.g. /etc/apache2/vhosts.d/your_vhost.conf):
<IfModule mod_rpaf.c> RPAFenable On RPAFsethostname On RPAFproxy_ips 85.12.6.171 </IfModule>
Change the bold IP address to your nginx rproxy IP address
Might be safe to run “apache2ctl configtest” to make sure you don’t have any errors in your config file(s).
And restart Apache. This makes it show the correct IP address in its log files.
Next on my to do list, getting it to actually cache something.
Leave a Reply…