我有一个域有3个子域:
- example.com (main domain)
- api.example.com
- blog.example.com
- support.example.com (just a cname to point to zendesk)
我在 Nginx 上有这3个配置:
api
# HTTP server
server {
listen 80;
server_name api.example.com;
return 301 https://api.example.com$request_uri;
}
# HTTPS server
server {
ssl on;
listen 443;
server_name api.example.com;
ssl_certificate APIcert.crt;
ssl_certificate_key APIcert.key;
#root configuration.....
}
blog
server {
listen 80;
server_name blog.example.com;
root /var/www/blog;
index index.php index.html index.htm;
site/main domain
server {
listen 80;
listen 443 ssl;
server_name www.example.com;
return 301 https://example.com$request_uri;
location ~ \.(php|html)$ {
deny all;
}
}
server {
listen 80;
server_name example.com;
return 301 https://example.com$request_uri;
location ~ \.(php|html)$ {
deny all;
}
}
server {
ssl on;
listen 443 ssl;
ssl_certificate mycert.crt;
ssl_certificate_key mycert.key;
server_name example.com;
root /var/www/frontend;
.....
}
MY PROBLEM :
-
子域api.example没问题!
-
如果我尝试在HTTP上使用www访问主域,则浏览器会重定向到https://example.com . 但是当我尝试使用www和https,https://www.example.com访问主域时,浏览器尝试从api访问SSL CERT .
-
在我尝试访问主域并重定向到HTTPS后,我没有HTTPS的其他子域重定向到https并显示错误,因为他们尝试从api使用SSL CERT .
-
示例:如果我尝试访问http://blog.exemple.com,则firefox重定向到https://blog.example.com并显示SSL错误 .
-
这是一段显示this problem的视频
-
域名在线,你可以在http://blog.alooga.com.br上测试,http://alooga.com.br
2 回答
您的Web服务器设置为
Strict-Transport-Security max-age=16070400; includeSubdomains
.这将告诉Web浏览器仅使用https请求您的域 . 如果您希望通过不安全的http访问子域
blog
,则需要从HTTP严格传输安全性(HSTS)中删除includeSubdomains
并使用其他浏览器(或清除Firefox) .https://www.ssllabs.com/ssltest/analyze.html?d=alooga.com.br
您收到SSL错误消息,因为您没有
blog.alooga.com.br
域的SSL证书 .SSL error message for your reference: