【发布时间】:2022-11-11 04:14:00
【问题描述】:
我想用不同的服务器块处理 sub.domain.com 和 domain.com 。 所以我创建了以下配置:
server {
listen 443 ssl;
server_name sub.domain.com;
location / {
...
}
}
server {
listen 443 ssl;
server_name domain.com;
location / {
...
}
}
对 sub.domain.com 的请求由第一个服务器块正确处理。但是对 domain.com 的请求还由第一个处理。
为什么?
根据我从文档中了解到的情况,对 domain.com 的请求不应与 sub.domain.com 匹配?
【问题讨论】:
-
使用
nginx -T(大写T)查看所有包含文件的整个配置。检查server块是否与确切的listen和server_name指令一起出现。例如,您是否使用www.domain.com而不是domain.com进行测试?名称中是否有拼写错误或缺少;?
标签: nginx nginx-config