将 Linux 服务器的子域名 (*.example.com) 列入白名单

将 Linux 服务器的子域名 (*.example.com) 列入白名单

我需要将一些文件迁移到 Google Drive,我们的问题是,在此过程中 Drive 需要联系我们的图片服务器。我们将这些图片放在一个常规 Apache 服务器中,该服务器监听端口 80。

我尝试在 Iptables 中使用一些 fqdn,但尽管它适用于该域,但 Google 每次都会通过不同的代理访问我们,由于 iptables 的工作方式,无法将其列入白名单。google 代理语法:google-proxy-xx-xx.google.com

有什么办法可以只允许这些子域名访问我们的服务器?谢谢!

答案1

我们使用 Squid3 并在 IPtables 中将端口重定向从端口 80 到 3128(默认 Squid 端口)来实现此目的。

然后我们按照这篇文章在 Squid 配置文件中配置通配符: https://kudithipudi.org/2015/12/15/how-to-enable-wildcard-domains-in-squid/

这是 squid 文档中最相关的部分:

http_port 3128 accel defaultsite=<your server name> vhost
# And the IP Address for it - adjust the IP and port if necessary
cache_peer 127.0.0.1 parent 80 0 no-query originserver name=hp
acl <acl-name> srcdomain .google.com
http_access allow <acl-name>

其中说用你的 DNS 名称更改它,如果你没有任何 DNS 名称,只需修改 /etc/hosts 文件以指向 127.0.0.1

请记住,此解决方案适用于在同一台机器上运行的 apache 服务器。

答案2

iptables可以根据静态信息过滤流量,因此它不符合您的需求。

你可以做的是使用 IF 语句保护 Apache 中的图像文件夹,例如<If "req('Host')..."> 有关此指令的更多信息这里

攻击者仍然有可能(至少在理论上)构造一个 HTTP 请求,其标头与你的安全设置完全匹配

相关内容