大网数据广告活动
网站运营与故障问答

Apache not logging referrer in all cases

· 52CE 我爱测

I have a Wordpress site hosted on Vultr, using Plesk Onyx with Apache + Nginx. I've done this same setup for other sites and never had issues, but for this new site I am seeing some odd behavior when clicking links to the site. I…

问题原文

原帖链接 · Mike · CC BY-SA 4.0

I have a Wordpress site hosted on Vultr, using Plesk Onyx with Apache + Nginx. I've done this same setup for other sites and never had issues, but for this new site I am seeing some odd behavior when clicking links to the site.

I noticed because Google Analytics never flags any traffic as being from a referral source. All the traffic I expect to show as Referral is showing as Direct. After looking at my Apache access logs, it seems when I click a link from some other websites, there is no referrer being logged.

This isn't the case for all links. Social platforms like Twitter, Instagram, and Facebook all get logged with the expected referrer information. Also, organic traffic and CPC/Ads traffic is also showing up as expected. It's just a handful of links from other sites that aren't logging.

Here are a few example entries from the access logs. Some contain a valid referrer (Twitter, for example) while others just contain a -. For some of these cases, I was tailing the access log while clicking a link from another site so I know it should have a valid referrer:

X.X.X.X - - [10/Jun/2019:03:06:10 +0000] "GET / HTTP/1.0" 200 12153 "https://twitter.com/PxJVBrEB7T" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:67.0) Gecko/20100101 Firefox/67.0"
X.X.X.X - - [10/Jun/2019:03:12:37 +0000] "GET / HTTP/1.0" 200 13535 "https://twitter.com/PTVIpLWqE9" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:67.0) Gecko/20100101 Firefox/67.0"
X.X.X.X - - [10/Jun/2019:03:50:39 +0000] "GET / HTTP/1.0" 200 12308 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:67.0) Gecko/20100101 Firefox/67.0"

Is it possible Apache is misconfigured and dropping the referrer information? Or is it possible it's something to do with the referring websites?

There are multiple referring websites where links aren't showing up properly in the access log, so I suspect it's on the server side but I'm not sure what more to check.

已采纳解答

原帖链接 · MrWhite · CC BY-SA 4.0

...clicking a link from another site so I know it should have a valid referrer

The only way to "know" whether it should have a valid referrer logged is if you see the HTTP Referer header as part of the request.

Whilst it's possible for the user to simply block the Referer header that the browser sends (probably not the issue in your case), the website can also trivially block the sending of the Referer header using the Referrer-Policy HTTP response header. Or simply adding the rel="noreferrer" attribute directly to the anchor. These techniques are supported by all major browsers these days.

Note that, by default, the browser will not send the Referer header when you navigate from HTTPS to HTTP. Which corresponds to Referrer-Policy: no-referrer-when-downgrade. (Although this doesn't seem to be the problem in your case, looking at your log extract.)

This is the most probable cause of the Referer not be logged - it's not being sent in the request. Particularly since you are seeing the Referer being logged for some sites.

Whilst it is technically possible on Apache to have a custom log format based on different requests - this seems very unlikely to be the cause. This would be a very deliberate action, rather than a simple "misconfiguration" IMO.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2019-06-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。