Home >Backend Development >PHP Tutorial >nginx empty host header

nginx empty host header

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-29 09:13:091356browse

Host header

This concept comes from the windows IIS server; we can simply understand that a host header is a host;

nginx prohibits empty host header configuration

can distribute requests and reverse proxy based on domain name and location;
For example,

<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>

this prohibits empty host header access;

nginx sets the domain name that can be forwarded

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>

Configure two virtual hosts on this machine, one is www.test.com and the other is localhost;

The host binding is (modify the /etc/hosts file):

<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>

can now be accessed through localhost and www.test.com, but access through www.test1.com is rejected and a 404 error is reported;

'). addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the nginx empty host header, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn