First time setting up Nginx and my goal is to have example.com with a static 'index.html' page served with a minimalist config, nothing more. I also want to drop the www subdomain. Here are my sites-available server blocks:
server { server_name www.example.com; return 301 $scheme://example.com$request_uri; } server { server_name example.com; root /var/www/example.com/; index index.html index.htm; location / { try_files $uri $uri/ /index.html; } }
If I use www.example.com or example.com they work fine, with www automatically dropped.
My issue is I can type anything after example.com and the index.html page still loads, like example.com/ABC or example.com/12345. These pages don't exist, why are the URLs accepted? I would expect any URL other than the domain root to return a 404 page instead.
This is probably a very simple issue but I've tried searching here & in the docs and I'm coming up with nothing so far.