V
V
Vladimir Ryzhov2020-02-17 20:11:08
Apache HTTP Server
Vladimir Ryzhov, 2020-02-17 20:11:08

On the VPS, in the apache access.log, instead of the visitor's IP, the external IP of the VPS itself is recorded. How to record the desired IP?

Of course, I don’t mind knowing IP vps all the time, but I still want the IP of the visitor.
PS I set up "with a dictionary".

CustomLog   /var/www/domains/site.ru/logs/.access_log combined


<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
</IfModule>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Foxcloud Foxcloud, 2020-02-18
@AprelVovanya

Good afternoon. You need to make small changes in the settings block you specified, replace %h with %{X-Forwarded-For}i :
CustomLog /var/www/domains/site.ru/logs/.access_log combined
LogFormat "%{X-Forwarded-For }i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

V
Viktor Taran, 2020-02-18
@shambler81

The problem is related to the fact that you use the apache + nginx bundle on your server,
as a result, the call to Apache comes from nginx, in fact, it writes its logs. Mod-rpaf
is used to fix this problem . Its essence is that it substitutes real IPs of nginx visitors instead of proxy IPs in the logs. There are a couple more topics that he allegedly does, but this is crap, since all the mana on the Internet is written with an error and the protocol substitution does not actually work, but this does not apply to the point. All you need to do is go to its config and set the value correctly. RPAFproxy_ips

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question