Nginx Empty Host Header

Source: Internet
Author: User
Tags to domain
Main head

This concept comes from the Windows IIS server; We can simply understand that a host header is a hostname;

Nginx Disable empty host header configuration

Can distribute requests according to domain name and location, reverse proxy;
Such as

server {        80;        server_name _;   ##标示空主机头        location / {                root html;                return404;        }        location ~ /.ht {                all;        }    }

This disables the empty host header access;

Nginx Set the domain name that can be forwarded

Ss

server {Listen the;server_name www. Test. com;Location/{root HTML;Index Index. htmlIndex. htm;}} server {listen the;server_name localhost;#charset koi8-r;#access_log Logs/host.access.log main;Location/{root HTML;Index Index. htmlIndex. htm;}#error_page 404/404.html;# REDIRECT Server error pages to the static page/50x.html#Error_page -502503504/ -x. html;Location =/ -x. html{Root HTML;} Location ~ (favicon. ico) {Root HTML;}    }

In the native configuration of two virtual host, one is www.test.com, one is localhost;

And the host binding is (modifies the/etc/hosts file):

127.0.0.1       localhost127.0.0.1  www.test.com127.0.0.1  www.test1.com

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

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the Nginx empty host header, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.