zno2

如何执行request的

http://nginx.org/en/docs/http/request_processing.html

按照优先级由上至下

1)匹配监听的端口

server {
    listen      80;
    ...
}

server {
    listen      8080;
    ...
}

2)匹配 request header (Host)

 

server {
    listen      80;
    server_name www.baidu.com;
    ...
}

server {
    listen      80;
    server_name zhidao.baidu.com;
    ...
}

3)  匹配到了listen 未匹配到 server_name

Nginx will route the request to the default server for this port.

① 隐式 default server (第一个)

server {
    listen      80;
    ...
}

server {
    listen      80;
    ...
}

②显示 default server

server {
    listen      80;
    ...
}

server {
    listen      80 default_server;
    ...
}

 

posted on 2023-06-06 13:16  zno2  阅读(9)  评论(0编辑  收藏  举报

导航