I've answered this question so many times I'm thinking of finding a way to make it generic so I could share it when there's a question is asked.
Here's the other answers if you would like to look at it
- Nginx Subdomain accessible on subdomain its not configured for
- nginx subdomain ssl redirect redirects top level domain
- nginx reverse proxy redirecting to wrong domain
you can read on any one why this is happening, on this reference link How nginx processes a request
Simple answer is a small server block to prevent it
server {
listen 80 default_server;
# return a code maybe or do any thing
return 404;
}
of course reload nginx after that to reflect the settings.