我有* .example.com的SSL通配符證書,它對根域無效。我想的Nginx在Ubuntu 14.04至Nginx重定向根域不在SSL證書中
- 只接受對已定義的主機請求
- 重定向爲根域和WWW子域中的所有HTTP請求到https WWW子域名
- 只在端口443根域回報404 ,例如如果reuqest是 https://example.com
我設法實現1和2與複製下面的配置。
server {
#listen 80;
#isten 443;
return 404;
}
server {
listen 80;
server_name example.com www.example.com;
return 301 https://www.example.com$request_uri;
}
server {
listen 443 ssl;
#certificate and key referenced in common.conf
server_name www.example.com;
root /usr/share/nginx/html/example.com;
index index.php index.html index.htm;
include common/common.conf;
}
當我從上面的第二個和第三個行刪除註釋標記,希望只爲https://example.com返回404 - 沒有什麼作品。例如,我在Chrome中獲得了ERR_CONNECTION_CLOSED,用於https://www.example.com/和http://ww.example.com/。
我應該怎樣做1),2)和3)?
非常感謝。