为什么Nginx选择错误的服务器来路由收到的请求?

时间:2018-08-06 12:58:52

标签: http nginx https http-headers

我使用具有以下配置的Nginx:

http {
    log_format main '$remote_addr [$time_local] "$http_host" "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';
    access_log logs/access.log main;
    server {
        listen 443 ssl;
        server_name example.com;
        access_log logs/example.log main;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_certificate example.crt;
        ssl_certificate_key example.key;
    }
    server {
        listen 443 ssl;
        server_name cp.example.com;
        access_log logs/cp_example.log main;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_certificate cp_example.crt;
        ssl_certificate_key cp_example.key;
    }
}

当有人请求“ https://cp.example.com/ ...”时,我假设可以在“ cp_example.log”文件中看到此请求。令人惊讶的是,我在“ example.log”文件中找到了此请求,“ $ http_host ”为“ cp.example.com:443 ”。为什么Nginx选择错误的服务器来路由此请求?另外,假设域“ example.com”和“ cp.example.com”都指向IP地址“ 1.2.3.4”,该Nginx服务器将与请求一起路由到“ https://1.2.3.4/ ...”?谢谢。

0 个答案:

没有答案