$ _ SERVER不能设置['HTTP_HOST'] [英] $_SERVER['HTTP_HOST'] not set

查看:664
本文介绍了$ _ SERVER不能设置['HTTP_HOST']的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到很多的流量到我的PHP页面,但没有变量 $ _ SERVER ['HTTP_HOST'] 设置。

I am getting lot of traffic to my php pages but without the variable $_SERVER['HTTP_HOST'] set.

这交通就像每秒1次命中。我不知道它可能是什么,但对于降低服务器负载我在每个PHP页面的顶部这样做:

This traffic is like 1 hit per second. I don't know what it could be, but for reducing server load i am doing this at the top of every php pages:

if (!isset($_SERVER['HTTP_HOST']))
    exit;

你知道这是什么原因?它是安全的退出,只要 HTTP_HOST 没有设置?

普通用户可以访问我的网页没有设置 HTTP_HOST

Can a normal user visit my pages without setting HTTP_HOST?


  • PHP版本:5.2.0-8

  • 阿帕奇:2.2.3

推荐答案

嗯,可能还有阿帕奇虚拟连接。请您访问内部的虚拟连接的日志,论文被用于由主Apache进程发送命令给他的孩子进程(如自杀自己,或者我们需要重新加载的conf)。和论文的连接在HTTP制作/ 1.0没有主机集。

Mmm, might be as well the "apache dummy connections". Check you access logs for "internal dummy connection", theses are used by the master apache process to send orders to his child processes (like suicide yourself, or we need to reload conf). And theses connections are made in HTTP/1.0 without HOST set.

http://wiki.apache.org/httpd/InternalDummyConnection

论文#$!#SH#F#CK * $!连接使得很多虫子围在那里,(缓存的东西,没有HTTP / 1.1,等等),一个简单的解决方案是不具有基于您的主机名Virtuahost为您服务主要应用为默认的虚拟主机,保持一个非常简单的默认虚拟主机使用'它的工作原理网页,或者说很简单:如果你得到这个页面你可以尝试获取与HTTP / 1.1支持地方浏览器一样,一个静态页面,然后所有的HTTP / 1.0通信或通过人IP访问您的服务器只,不会在你的实际应用。

Theses #$!"#sh#f#ck*$! connections are making a lot of bugs around there, (cache things, no HTTP/1.1, etc). One 'simple' solution is not having your hostname based Virtuahost serving you main application as the default virtualhost. Keep a very simple default virtualhost with the 'it works' page, or something very simple "if you get this page you might try to get a browser with HTTP/1.1 support somewhere", as a static page. Then all HTTP/1.0 traffic or people accessing your server by IP only, will not be in your real application.

要完成我今年见过一个公司,代理不好去除所有的传出HTTP流量的主机头。但载文坏人在dumbs,我不认为有很多人在HTTP / 1.0浏览仍然没有主机。

To be complete I've seen a company this year with bad proxies removing the Host header from all their outgoing HTTP traffic. But theses bad guys are dumbs, I don't think there's a lot of people still browsing in HTTP/1.0 without hosts.

这篇关于$ _ SERVER不能设置['HTTP_HOST']的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆