Detailed explanation of the meaning of server and server_name of nginx configuration file nginx.conf

Transfer from: https://blog.csdn.net/qq_40737025/article/details/85053164

 

When I was learning nginx, I was troubled by the meaning of server_name for a long time. It's checking information and asking people for advice. Finally, I tested it out by myself.

You found this article to show that you have gone through the basic configuration, but do not understand the meaning.

The server name is the identification mark of the virtual server, which is matched to a specific server block and forwarded to the corresponding application server.

This article mainly explains the meaning of server_name. At the end of the article, it will explain the server's entire access request process; please pay attention to the red text in the text;

One-row arrangement

server {

listen ip:端口;

# 当listen出现了ip时,server_name就失去了意义。所以不配置也罢了。

#server_name 域名;


access_log 日志地址1;

error_log 日志地址2;


location / {

root /data/www/151;

index index.html index.htm;

}

}

​​

When the client accesses the server through the domain name, it will put the domain name and the resolved ip in the request. When the request arrives in nginx. Nginx will match the ip first. If the corresponding ip is not found in the listen, it will match the domain name. After the match is successful, the port will be matched. When these three steps are completed, the resource corresponding to the location of the corresponding server will be found.

For more detailed content, see https://blog.csdn.net/qq_40737025/article/details/85053164

Guess you like

Origin blog.csdn.net/suixinsuoyu12519/article/details/112310850