弱电论坛
标题:
apache下防止别人域名解析到我们主机上,apache禁止空主机头.
[打印本页]
作者:
卡西达
时间:
2013-4-30 14:01
标题:
apache下防止别人域名解析到我们主机上,apache禁止空主机头.
1.为了防止域名解析恶意指向,我们需要禁止apache默认的空主机头,操作如下:
vi /etc/httpd/conf/httpd.conf编辑配置文件,在你的站点配置之前再增加一个站点(红色字体部分是我们要增加的,蓝色字体部分代表你正在使用的站点配置)
NameVirtualHost *
<VirtualHost *:80>
ServerAdmin yourmail@mail.com
DocumentRoot /error
ServerName abc.com
</VirtualHost>
<VirtualHost *:80>
ServerAdmin yourmail@mail.com
DocumentRoot "你的站点路径"
ServerName yourWebsite.com
ServerAlias *.yourWebsite.com
</VirtualHost>
复制代码
2.在httpd.conf 里面找不到像上面的NAMEVistualHost的话,就是他刚开始安装的时候就已经已经输入域名那些了,
进入apache安装目录 编辑conf目录下的httpd.conf文件: 找到 # Virtual hosts #Include conf/extra/httpd-vhosts.conf 把Include conf/extra/httpd-vhosts.conf前面的#去掉,进入conf\extra\目录 编辑httpd-vhosts.conf文件
加入
<PRE> <PRE><SPAN style="COLOR: #00cd00"><SPAN style="COLOR: #ff0000"></SPAN></SPAN><P>NameVirtualHost *
<VirtualHost *:80>
ServerAdmin <A href="mailto:yourmail@mail.com"><FONT color=#0000ff>yourmail@mail.com</FONT></A>
DocumentRoot /error
ServerName abc.com
</VirtualHost></P><P><VirtualHost *:80>
ServerAdmin <A href="mailto:webmaster@dtaojindai.com"><FONT color=#0000ff>webmaster@dtaojindai.com</FONT></A>
DocumentRoot D:/EmpireServer/web
ServerName taojindai.com
ServerAlias <A href="http://www.taojindai.com/"><FONT color=#0000ff>www.taojindai.com</FONT></A>
</VirtualHost>
</P></PRE></PRE>
复制代码
作者:
分特范戈
时间:
2013-4-30 17:06
如果别人域名解析过来有什么害处么?
欢迎光临 弱电论坛 (http://bbs.rdzjw.com/)
Powered by Discuz! X3.2