Detailed principle and process of virtual host access based on domain name in combination with HTTP

Source: Internet
Author: User
Tags nginx server

How the server responds

[[email protected] blog]# netstat-lntup|grep 80tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 5784/nginx

Start the Nginx service, the system listens to the 80 port of this machine (80 port is all the network card of this machine), so as long as the client requests the IP 80 port of any piece of network card, Nginx will respond, the client requests 80 port of any NIC IP, Nginx Service will look at the request message in which there is a call host:www.etiantian.org, Nginx Server received the request message after the request domain name, port, Will find the virtual host from the nginx.conf configuration file, if the client's request message does not have a virtual hostname only 1 IP address name, then the Nginx server can only send the default first virtual host name in the nginx.conf configuration file in response to the message to the client. The first default virtual host named Www.etiantian.org in the article below

That is, if the client directly input nginx IP address, then the NGINX server response message when the default response to the first virtual host name to the client.

[[email protected] conf]# cat nginx.confworker_processes  1;events {     worker_connections  1024;} http {    include       mime.types;     default_type  application/octet-stream;    sendfile         on;    keepalive_timeout  65;     server {        listen        80;        server_name  www.etiantian.org;         location / {             root   html/www;             index  index.html index.htm;        }    }    server {         listen       80;         server_name  bbs.etiantian.org;         location / {            root    html/bbs;            index   index.html index.htm;        }    }     server {        listen        80;        server_name   blog.etiantian.org;        location / {             root   html/blog;             index  index.html index.htm;        }     }}


This article is from the "Sandshell" blog, make sure to keep this source http://sandshell.blog.51cto.com/9055959/1957731

Detailed principle and process of virtual host access based on domain name in combination with HTTP

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.