主机头
这个概念来源于windows IIS服务器;我们可以简单理解为,一个主机头就是一个host;
nginx 禁止空主机头配置
可以根据域名和location来分发请求,反向代理;
譬如
<code>server { listen <span>80</span>; server_name _; <span>##标示空主机头</span> location / { root html; <span>return</span><span>404</span>; } location ~ /.ht { deny <span>all</span>; } }</code>
这样就禁止空主机头访问;
nginx 设置可以转发的域名
ss
<code>server { listen <span>80</span><span>;</span> server_name www<span>.test</span><span>.com</span><span>;</span> location / { root html<span>;</span> index index<span>.html</span> index<span>.htm</span><span>;</span> } } server { listen <span>80</span><span>;</span> server_name localhost<span>;</span><span>#charset koi8-r;</span><span>#access_log logs/host.access.log main;</span> location / { root html<span>;</span> index index<span>.html</span> index<span>.htm</span><span>;</span> } <span>#error_page 404 /404.html;</span><span># redirect server error pages to the static page /50x.html</span><span>#</span> error_page <span>500</span><span>502</span><span>503</span><span>504</span> /<span>50</span><span>x</span><span>.html</span><span>;</span> location = /<span>50</span><span>x</span><span>.html</span> { root html<span>;</span> } location ~ (favicon<span>.ico</span>) { root html<span>;</span> } }</code>
在本机配置了两个虚拟主机,一个是www.test.com,一个是localhost;
而host绑定为(修改/etc/hosts文件):
<code><span>127.0</span><span>.0</span><span>.1</span> localhost <span>127.0</span><span>.0</span><span>.1</span> www<span>.test</span><span>.com</span><span>127.0</span><span>.0</span><span>.1</span> www<span>.test</span>1<span>.com</span></code>
现在可以通过 localhost和 www.test.com访问,而通过www.test1.com访问则被拒绝,报404错误;
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });以上就介绍了nginx空主机头,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。