Apache 2.2.15 doesn't log referer as it's set in httpd.conf

Alles, was den Apache betrifft, kann hier besprochen werden.

Apache 2.2.15 doesn't log referer as it's set in httpd.conf

Postby bhy » 21. August 2019 14:09

Hello. I'm kind of new to these things so please bear with me.

I have the following in my /etc/httpd/conf/httpd.conf:
Code: Select all
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

And the following in my /etc/httpd/conf.d/vhosts.conf:
Code: Select all
CustomLog "/var/log/httpd/bioma.cz-access.log" combined

I suppose the keyword combined means that the LogFormat from /etc/httpd/conf/httpd.conf should be used for /var/log/httpd/bioma.cz-access.log, am I right?
However, I'm still not getting the referer info in the log file.
The line in the log file looks like this:
Code: Select all
[21/Aug/2019:03:21:32 +0200] 66.249.79.172 - "GET /index.php?route=product/product&tag=vegan&sort=p.price&order=ASC&page=3&limit=50&product_id=5757 HTTP/1.1" 22598

I did a grep -R on the whole /etc/httpd/ directory and there is no other occurrence of LogFormat that could override the setting.

I found a solution to a similar problem, but it was for a Debian-based system. I have CentOS 6.10 and I don't have the file that was part of the Debian solution.
What am I missing?
Thank you very much
Petr Břeň
bhy
 
Posts: 2
Joined: 21. August 2019 13:45
XAMPP version: Apache/2.2.15 (CentOS)
Operating System: CentOS 6.10 (Linux)

Re: Apache 2.2.15 doesn't log referer as it's set in httpd.c

Postby Nobbie » 22. August 2019 11:44

Add the line with the definition of the LogFormat (LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined) into the VirtualHost where you also added the CustomLog. I dont think that a server wide declaration of LogFormat works in the scope of a VirtualHost. Usually each VirtualHost has its own server environment. The LogFormat of your VirtualHost actually is the default format instead of the format in your httpd.conf.

These two lines should be added to all of your VirtualHosts (but replace the path in CustomLog for each VirtualHost, if you have more than one VirtualHost):

Code: Select all
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog "/var/log/httpd/bioma.cz-access.log" combined
Nobbie
 
Posts: 11211
Joined: 09. March 2008 13:04

Re: Apache 2.2.15 doesn't log referer as it's set in httpd.c

Postby bhy » 29. August 2019 13:44

Thank you very much, works exactly as needed.
bhy
 
Posts: 2
Joined: 21. August 2019 13:45
XAMPP version: Apache/2.2.15 (CentOS)
Operating System: CentOS 6.10 (Linux)


Return to Apache

Who is online

Users browsing this forum: No registered users and 4 guests