以前,当我的网站根本没有 SSL/https 时,尝试访问它会失败。例如, curl 将返回:
curl: (7) couldn't connect to host
现在我已经在子域中实现了 SSL,我想在所有其他域中模拟以前的行为。
例如:我的https://api.example.com按预期工作。但是现在访问https://www.example.com会返回 403。
# HTTPS server
server {
listen 443;
server_name api.example.com:
ssl on;
ssl_certificate server.crt;
ssl_certificate_key server.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app;
}
}
server {
listen 443 default_server;
server_name _;
ssl on;
ssl_certificate server.crt;
ssl_certificate_key server.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
deny all;
}
我应该如何配置 Nginx,所以访问不应该有 SSL 的子域(https://www.example.com),它会表现得好像主机无法连接?