我遇到了一个小的子域重定向问题。这是我的配置:
server {
listen 80 default_server;
server_name sub4.example.com sub3.example.com sub2.example.com sub1.example.com www.example.com;
access_log /var/log/nginx/www.example.com_access.log;
error_log /var/log/nginx/www.example.com_error.log;
location / {
return 301 https://$server_name$request_uri;
}
}
server {
listen 443 ssl spdy default_server;
server_name sub4.example.com sub3.example.com sub2.example.com sub1.example.com www.example.com;
root /srv/www/www.example.com/current/public;
ssl_certificate ssl-certificates/wildcard.example.com.crt;
ssl_certificate_key ssl-certificates/wildcard.example.com.key;
access_log /var/log/nginx/www.example.com_access.log;
error_log /var/log/nginx/www.example.com_error.log;
...
}
所有https
个域都按预期工作,但所有http
个请求都重定向到https://sub4.example.com
。
任何人都知道为什么会发生这种情况?