I'm trying to configure an nginx server with TLS. It successfully works when I use the IP address, but not with the domain name.
For instance, https://111.111.111.111/ works, but https://example.com does not (IP and domain are redacted).
DNS address could not be found. Diagnosing the problem.
Almost the entire configuration is the default other than listening on port 433 and adding the SSL certificates.
Here's my entire config (with all the boilerplate comments removed).
# /etc/nginx/sites-available/default
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl on;
ssl_certificate /etc/nginx/ssl/my-cert.pem;
ssl_certificate_key /etc/nginx/ssl/my-key.pem;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name example.com;
location / {
try_files $uri $uri/ =404;
}
}
Debug steps
I don't have an exhaustive list of everything I've tried, but here are some of the things I remember:
- Double-checked the DNS on Cloudflare points to the correct IP address (it's an A record pointing to a IPv4 address)
- Double-checked the DNS propogated
ping https://example.com
resolves to the correct IP address- Turned all firewalls off
- Tried on several browsers on multiple devices
- Ensured this is not a
www.example.com
vsexample.com
mismatch