Apache 接受对其他服务器的请求吗?

Apache 接受对其他服务器的请求吗?

我在使用 apache 服务器(Amazon 的 CentOS VPS)时遇到了问题。当 apache 启动时,它会开始接收数百个请求,以下是日志的示例:

173.208.216.165 - - [25/Jan/2015:18:23:11 +0000] "GET http://go.padstm.com/resources/img/iebt.png HTTP/1.0" 200 36023 "http://go.padstm.com/?id=173374&t=iframe&var=33110" "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"

路径 /resources/img/iebt.png 在我的服务器中,但不在 go.padstm.com 中。最奇怪的是,apache 正在接受所有请求。其他示例:在这种情况下,整个资源不在我的服务器中,但 apache 返回 200:

198.204.239.250 - - [25/Jan/2015:19:04:39 +0000] "GET http://fstads.com/show.php?z=26&pl=494&j=1&code=1422237874120 HTTP/1.0" 200 10819 "http://financezhen.com/?p=186#respond" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:2.2a1pre) Gecko/20110324 Firefox/4.2a1pre"

我不知道为什么这些请求会到达我的服务器,或者为什么它返回 200...

此外,当 apache 启动并启用模块 prefork 时,它会启动多个 httpd 进程。如果启用了 worker 模块,它会启动多个线程。好的,但在这两种情况下,apache 最终都会消耗服务器的所有 CPU 和内存,并且没有流量定向到我的服务器。

更多信息:ProxyRequests 已关闭。另外:我正在使用基于 ip 的虚拟主机:

NameVirtualHost xxx.xxx.xxx.xxx:80

<VirtualHost xxx.xxx.xxx.xxx:80>
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    DocumentRoot /var/www/html/w3prod
    ServerAdmin admin@localhost
    UseCanonicalName Off
    CustomLog /var/log/httpd/w3prod.mydomain.com combined
    ErrorLog /var/log/httpd/w3prod_error.mydomain.com
</VirtualHost>
<VirtualHost xxx.xxx.xxx.xxx:80>
    ServerName picfarm.mydomain.com
    ServerAlias www.picfarm.mydomain.com
    DocumentRoot /var/www/html/picfarm
    ServerAdmin admin@localhost
    UseCanonicalName Off
    CustomLog /var/log/httpd/picfarm.mydomain.com combined
    ErrorLog /var/log/httpd/picfarm_error.mydomain.com
</VirtualHost>
<VirtualHost xxx.xxx.xxx.xxx:80>
    ServerName test.mydomain.com
    ServerAlias www.test.mydomain.com
    DocumentRoot /var/www/html/engine-test
    ServerAdmin admin@localhost
    UseCanonicalName Off
    CustomLog /var/log/httpd/test.mydomain.com combined
    ErrorLog  /var/log/httpd/test_error.mydomain.com
    ProxyRequests Off
    ProxyPreserveHost On
    <Proxy *>
            Order deny,allow
            Allow from all
    </Proxy>
    ProxyPass /bosh http://xxx.xxx.xxx.xxx:7070/http-bind/
    ProxyPassReverse /bosh http://xxx.xxx.xxx.xxx:7070/http-bind/
    ProxyPass / http://xxx.xxx.xxx.xxx:8080/
    ProxyPassReverse / http://xxx.xxx.xxx.xxx:8080/
</VirtualHost>

任何帮助都将不胜感激。谢谢!

答案1

这里的问题是,有人设置了他们自己域名的 DNS 记录,并将其指向您的 IP,而不是他们自己服务器的 IP。没有办法阻止某人这样做。

解决该问题的基础是:

  • 您可以联系 padstm.com 域名的所有者并告知他们错误。如果这确实是一个错误,他们可能会修复它。但如果这是垃圾邮件发送者,他们会很乐意继续辱骂您……

  • 您可以向托管公司申请新的 IP 地址。您需要更改自己的 DNS 记录以指向新 IP,并让它们有时间从缓存中消失,然后再关闭旧 IP。

您还可以让 Apache 不提供任何包含不属于您的主机名请求的内容。其工作方式是,如果您向 Apache 发送请求,而请求的主机名列在其中一个 VirtualHosts 中,则将使用该 VirtualHost。但如果主机名未列在任何地方,则将默认使用第一个 VirtualHost。(我在这个答案,如果你感兴趣的话。)因此,你只需设置一个不提供内容的默认 VirtualHost。以下是示例配置

<VirtualHost xxx.xxx.xxx.xxx:80>
    ServerName default
    RewriteEngine On
    RewriteRule .* - [G]
</VirtualHost>

410 Gone这意味着,对于任何未列为ServerName或未包含在配置中的其他 VirtualHosts 中的主机名,请求的每个 URL 都将被重写以返回ServerAlias。此返回代码表示资源不存在并且永远不会再存在,客户端应停止尝试访问它。

如果您有兴趣查看服务器上抛出的内容,请设置合适的CustomLog指令ErrorLog来跟踪它。如果没有,请通过添加以下行将日志发送到 bitbucket:

CustomLog /dev/null common
ErrorLog  /dev/null

到 VirtualHost 配置

相关内容