子域未正确地从http重定向到https

时间:2015-03-04 17:32:53

标签: redirect nginx http-status-code-301 subdomain

我遇到了一个小的子域重定向问题。这是我的配置:

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

任何人都知道为什么会发生这种情况?

0 个答案:

没有答案