什么情况下HTTP_REFERER会为空

发布于 2024-11-27 05:14:06 字数 97 浏览 2 评论 0原文

我知道有可能得到一个空的 HTTP_REFERER。什么情况下会出现这种情况?如果我得到一个空的,是否总是意味着用户更改了它?获取空值与获取空值相同吗?在什么情况下我也会得到这个?

I know it's possible to get an empty HTTP_REFERER. Under what circumstances does this happen? If I get an empty one, does it always mean that the user changed it? Is getting an empty one the same as getting a null one? and under what circumstances do I get that too?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

秋意浓 2024-12-04 05:14:06

时,它可能为空或部分

  • 当最终用户在浏览器地址栏中输入站点 URL
  • 。通过浏览器维护的书签访问该网站。
  • 在某些浏览器中,在新窗口/选项卡/会话中将该网站作为首页访问。
  • 单击了具有限制性 的页面上的链接 标签。
  • 单击了具有限制性 Referrer-Policy 的页面上的链接标头。
  • 单击了具有 rel="noreferrer"< 的链接/代码>
  • 单击外部应用程序中的链接(即不是网络浏览器,例如 Flash)。
  • 从 https URL 切换为 http URL。
  • 安装了安全软件(防病毒/防火墙/等),该软件会从所有请求中删除引荐来源网址。
  • 位于代理后面,该代理从所有请求中删除引荐来源网址。
  • 以编程方式访问该网站(例如,curl),无需设置引荐来源网址标头(机器人!)。

It will/may be empty or partial when the enduser

  • entered the site URL in browser address bar itself.
  • visited the site by a browser-maintained bookmark.
  • visited the site as first page in a new window/tab/session, in some browsers.
  • clicked a link on a page having restrictive <meta name="referrer"> tag.
  • clicked a link on a page having restrictive Referrer-Policy header.
  • clicked a link having rel="noreferrer".
  • clicked a link in an external application (i.e. not a webbrowser, e.g. Flash).
  • switched from a https URL to a http URL.
  • has security software installed (antivirus/firewall/etc) which strips the referrer from all requests.
  • is behind a proxy which strips the referrer from all requests.
  • visited the site programmatically (like, curl) without setting the referrer header (bots!).
陌上青苔 2024-12-04 05:14:06

HTTP_REFERER - 由浏览器发送,说明浏览器查看的最后一个页面!

如果您出于任何重要原因信任 [HTTP_REFERER],则不应这样做,因为它很容易被伪造:

  1. 某些浏览器限制访问,不允许传递 HTTP_REFERER
  2. 在地址栏中键入地址将不会传递 HTTP_REFERER
  3. 打开一个新的浏览器窗口不会传递 HTTP_REFERER,因为 HTTP_REFERER = NULL
  4. 有一些浏览器插件出于隐私原因阻止它。一些防火墙和反病毒软件会这样做。

尝试这个 Firefox 扩展,您将能够设置您想要的任何标头:

@Master of Celebration:

Firefox:

扩展: refspoof, refontrol修改标题, no-referer

完全禁用:选项可在 about:config 中的“network.http.sendRefererHeader”下找到,并且您希望将其设置为 0 以禁用引荐来源网址传递。

Google chrome / Chromium:

扩展程序: noref< /a>,欺骗外部 noreferrer

完全禁用: Chnage ~/.config/google-chrome/Default/Preferences 或 ~/.config/chromium/Default/Preferences 并设置:

{
   ...
   "enable_referrers": false,
   ...
}

或者简单地将 --no-referrers 添加到快捷方式或在 cli 中:

google-chrome --no-referrers

Opera:

完全禁用: 设置>首选项>高级>网络,然后取消选中“发送引荐来源网址信息”

欺骗网络服务:

http://referer.us/

独立过滤代理(欺骗任何标头):

Privoxy

欺骗 http_referer使用时wget

'--referer=url'

使用curl时欺骗http_referer

-e, --referer

使用telnet欺骗http_referer

telnet www.yoursite.com 80 (press return)
GET /index.html HTTP/1.0 (press return)
Referer: http://www.hah-hah.com (press return)
(press return again)

HTTP_REFERER - sent by the browser, stating the last page the browser viewed!

If you trusting [HTTP_REFERER] for any reason that is important, you should not, since it can be faked easily:

  1. Some browsers limit access to not allow HTTP_REFERER to be passed
  2. Type a address in the address bar will not pass the HTTP_REFERER
  3. open a new browser window will not pass the HTTP_REFERER, because HTTP_REFERER = NULL
  4. has some browser addon that blocks it for privacy reasons. Some firewalls and AVs do to.

Try this firefox extension, you'll be able to set any headers you want:

@Master of Celebration:

Firefox:

extensions: refspoof, refontrol, modify headers, no-referer

Completely disable: the option is available in about:config under "network.http.sendRefererHeader" and you want to set this to 0 to disable referer passing.

Google chrome / Chromium:

extensions: noref, spoofy, external noreferrer

Completely disable: Chnage ~/.config/google-chrome/Default/Preferences or ~/.config/chromium/Default/Preferences and set this:

{
   ...
   "enable_referrers": false,
   ...
}

Or simply add --no-referrers to shortcut or in cli:

google-chrome --no-referrers

Opera:

Completely disable: Settings > Preferences > Advanced > Network, and uncheck "Send referrer information"

Spoofing web service:

http://referer.us/

Standalone filtering proxy (spoof any header):

Privoxy

Spoofing http_referer when using wget

‘--referer=url’

Spoofing http_referer when using curl

-e, --referer

Spoofing http_referer wth telnet

telnet www.yoursite.com 80 (press return)
GET /index.html HTTP/1.0 (press return)
Referer: http://www.hah-hah.com (press return)
(press return again)
_畞蕅 2024-12-04 05:14:06

如果使用新的推荐人政策标准草案来防止推荐人被拒绝,则该字段也将为空标头被发送到请求源。示例:

<meta name="referrer" content="none">

虽然 Chrome 和 Firefox 已经实施了引用者策略的草稿版本,但您应该小心对待它,因为例如 Chrome 需要 no-referrer 而不是 none(并且我也从未在某处见过)。

It will also be empty if the new Referrer Policy standard draft is used to prevent that the referer header is sent to the request origin. Example:

<meta name="referrer" content="none">

Although Chrome and Firefox have already implemented a draft version of the Referrer Policy, you should be careful with it because for example Chrome expects no-referrer instead of none (and I have seen also never somewhere).

煮酒 2024-12-04 05:14:06

BalusC 的名单很可靠。该字段经常显示为空的另一种情况是当用户位于代理服务器后面时。这与防火墙后面类似,但略有不同,因此为了完整起见我想提及它。

BalusC's list is solid. One additional way this field frequently appears empty is when the user is behind a proxy server. This is similar to being behind a firewall but is slightly different so I wanted to mention it for the sake of completeness.

倒数 2024-12-04 05:14:06

我发现浏览器引用的实现确实不一致。

例如,具有“download”属性的锚元素在 Safari 中按预期工作并发送引荐来源网址,但在 Chrome 中,引荐来源网址将为空或 Web 服务器日志中的“-”。

<a href="http://foo.com/foo" download="bar">click to download</a>

Chrome 中已损坏 - 未发送引荐来源网址。

I have found the browser referer implementation to be really inconsistent.

For example, an anchor element with the "download" attribute works as expected in Safari and sends the referer, but in Chrome the referer will be empty or "-" in the web server logs.

<a href="http://foo.com/foo" download="bar">click to download</a>

Is broken in Chrome - no referer sent.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文