【发布时间】:2018-01-10 08:54:52
【问题描述】:
我正在尝试让我的 nginx 的所有流量都重定向到 HTTPS,而与服务器名称无关。因此,任何其他虚拟主机都应重定向到其 HTTPS 对应物。
example.com -> https://example.com
test.com -> https://test.com
...
然而,它没有使用传入的$server_name 或$host(都尝试过),而是一直重定向到一个普通的https://_。我的配置不正确吗?
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$server_name$request_uri;
}
【问题讨论】: