Hi everyone,
I'm troubleshooting an Nginx configuration issue. Our website is accessible through an unrelated domain, causing duplicate URLs to appear in search engine results.
When I test with curl, I get different results:
HTTP:
HTTP/1.1 302 Moved Temporarily Location: https://www.example.com
HTTPS:
HTTP/1.1 200 OK Content-Type: text/html; charset=UTF-8
The configuration has a default HTTPS server:
server { listen 443 default_server ssl; server_name www.example.com; ssl_certificate /path/to/certificate.crt; ssl_certificate_key /path/to/private.key; root /var/www/website/htdocs; }
The unrelated domain doesn't appear to be explicitly configured in the virtual hosts I've checked.
What is the recommended way to configure Nginx so that unknown domains cannot serve the main website over HTTPS, while preserving existing redirects for known domains?
Thanks!
Source: r/nginx · by /u/FullSatsuma