My issue:
Sending a request to an HTTPS domain that is not configured in nginx but points to my server, you get the usual certificate error, but if you ignore that, nginx will send a 301 redirect to one of the configured servers (probably the 1st, but I haven’t investigated the order).
How I encountered the problem:
Some domain points to my IP for no reason.
Solutions I’ve tried:
Catch all for HTTP traffic works fine, but I can’t do a default_server for 443 without a cert. I could technically fetch the cert for the specific domain domain that is pointing over, but is that really the solution if the domain is something I don’t own or care about?
Version of NGINX or NGINX adjacent software (e.g. NGINX Gateway Fabric):
I tried on 1.18 and 1.24 so maybe there’s a change/fix in a later version?
Deployment environment:
Ubuntu 22-LTS, 24-LTS, cloud VM
Minimal NGINX config to reproduce your issue:
# catch-all
server {
listen 80 default_server;
server_name _;
return 444;
}
# Site something.tld with an http => https redirect
server {
listen 80;
server_name something.tld;
return 301 https://something.tld$request_uri;
}
server {
listen 443 ssl http2;
server_name something.tld;
# and all the ssl_ settings
}
Let’s assume the server IP is 1.2.3.4 and you have an /etc/hosts with this:
1.2.3.4 foobar.tld
Then you run curl test:
❱ curl -I http://foobar.tld
curl: (52) Empty reply from server
❱ curl -I https://foobar.tld
curl: (60) SSL: no alternative certificate subject name matches target hostname 'foobar.tld'
❱ curl -kI https://foobar.tld
HTTP/2 301
server: nginx
date: Thu, 16 Jul 2026 06:28:51 GMT
content-type: text/html
content-length: 162
location: https://something.tld
This last one is the one I have an issue with. How can I make it do nothing?
NGINX access/error log:
x.x.x.x - - [16/Jul/2026:09:19:31 +0200] "HEAD / HTTP/1.1" 444 0 "-" "curl/8.21.0" "-"
x.x.x.x - - [16/Jul/2026:09:18:32 +0200] "HEAD / HTTP/2.0" 301 0 "-" "curl/8.21.0" "-"