Not Getting Visitor Ip Address

Today I was finally able to find a fix for my visitor ip not showing up on wordpress.

Basically when some one would comment on a wordpress post, it would show the server ip address as the visitor ip address. This would happen because I have nginx running along with apache on the same server. Nginx serves as the proxy. To fix this issue, I followed the steps mention on this website:

First step is to enable mod_remoteip

sudo a2enmod remoteip

Once you’ve enabled you then need to open your Apache configuration file.

sudo nano /etc/apache2/apache2.conf

Add the following line at the very bottom of your Apache configuration file

RemoteIPHeader X-Forwarded-For

Now while you still have your Apache configuration file open you need to make one last edit to the line below.

LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined

Swap the h to and “a” (without quotation marks), so as below.

LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined

That’s it, all you need to do now is restart Apache using the line below and you should begin to see real IP addresses for your visitors in your Apache access logs.

sudo systemctl restart apache2

I am using Vesta CP and it works.


So empty here ... leave a comment!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.