Previously, when my site does not have SSL/https at all, trying to access it would fail. For example, curl would return:
curl: (7) couldn't connect to host
Now that I have implemented SSL in a subdomain, I would like to simulate the previous behavior in all other domains.
For example: my https://api.example.com works as expected. But now visting https://www.example.com to would return 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;
}
How should I configure Nginx, so visit subdomains which should not have SSL (https://www.example.com), it would behave as if the host can not be connected?
Instead of
deny all
, usereturn 444
instead.