大网数据广告活动
服务器运维问答

How to prevent other people from proxy_pass their own domains to my domain?

· 52CE 我爱测

People can use Nginx to proxy_pass to my domain and on the browser, the contents are mines, but on address bar it's their domains. How to detect when the requests are thru' proxy_pass and deny those? For example, when I purposely…

问题原文

原帖链接 · Dan D. · CC BY-SA 4.0

People can use Nginx to proxy_pass to my domain and on the browser, the contents are mines, but on address bar it's their domains.

How to detect when the requests are thru' proxy_pass and deny those?

For example, when I purposely proxy_pass to google.com, I get 404 error.

server {
  listen 80;
  server_name test.com;

  location / {
    proxy_pass https://google.com;
  }
}

Seems that it's not possible to prevent this, for example those people make the proxy behave just like a normal browser. However, how to prevent if they just use a simple Nginx proxy_pass?

已采纳解答

原帖链接 · Danila Vershinin · CC BY-SA 4.0

Theoretically, you can, but not without a lot of effort.

Supposedly, you are running an HTTP/2 capable website.

Detecting proxy_pass to your website can build upon the fact that these connections will always originate over HTTP/1.x and never via HTTP/2.

Then you can match that up with browser capabilities.

So, essentially, if you see an HTTP/2 capable browser connecting to your website over an older HTTP/1.x protocol, you can safely assume that it is over NGINX's proxy_pass or some other proxy (other than NGINX).

So while this could work, you'd cut off all clients who just browse through a proxy of some kind...

That is the passive approach.

The active approach is simply checking for a number of connections from the same IP address. You'd be checking the logs (e.g. Fail2ban or other log scanners) for many connections from the same IP address, having different user agents (or none).

An IP address with a lot of varying user agents/access is likely to be a proxy of some kind.

Finally, you can do RDNS check/whois queries to see whether a request is coming from a known hosting provider.

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

资料来源与适用范围

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

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

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