Awstat Logging a single IP on Nginx Server

When you see awstat logging a Single IP for any domains in a Nginx Server, note that Nginx is configured in port 82 and apache with port 80. Nginx will be running as reverse proxy for Apache, we don’t want our log file to record the proxy IP. We want the real IP as usual. Otherwise the log files will show only the Proxy IP. So we need to install mod_rpaf which is “Reverse Proxy Add Forward” module for Apache. Our older team used a module like “realip2_module” for doing this.

Install steps:

cd /usr/local/src
wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
tar -xzf mod_rpaf-0.6.tar.gz
cd mod_rpaf-*
apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c

Once installed, we need to load the module into Apache configuration. Since cPanel already has Include Editor for Apache, we will use that functions.

Login to WHM > Service Configuration > Apache Configuration > Include Editor > Pre Main Include > All Versions and paste following text:

LoadModule rpaf_module modules/mod_rpaf-2.0.so
RPAFenable On
RPAFproxy_ips 127.0.0.1 64.235.229.101 # replace the value with your server IP which are logged same on domlogs of domains 
RPAFsethostname On
RPAFheader X-Real-IP

Click Update > Restart Apache and Nginx.
Check and verify the IP from the logs.

Note: In this module we have one limitation is that, we need to add the IPs manually in RPAFproxy_ips.

Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: