[英]Nginx redirect http subdomains to https
我有一個帶有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.....
}
博客
server {
listen 80;
server_name blog.example.com;
root /var/www/blog;
index index.php index.html index.htm;
站點/主域
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;
.....
}
我的問題 :
您的Web服務器設置為Strict-Transport-Security max-age=16070400; includeSubdomains
Strict-Transport-Security max-age=16070400; includeSubdomains
。
這將告訴網絡瀏覽器僅使用https請求您的域。 如果要通過不安全的http訪問子域blog
,則需要從HTTP嚴格傳輸安全性(HSTS)中刪除includeSubdomains
,並使用其他瀏覽器(或清除Firefox)。
https://www.ssllabs.com/ssltest/analyze.html?d=alooga.com.br
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.