nginx defaults to returning 404 instead of 403 when the homepage does not exist
The domain was hijacked by a certain website, causing the entire site to be compromised. By setting up nginx, the specified domain is bound to a specific site, and then a forced return of 404 is implemented.
location = / { return 404; }
However, the homepage still returns a 403 code instead of the expected 404. To fix this, we need to make 404 work properly and then directly redirect the homepage to a non-existent resource. Job done.
location = / { index index.html return 404; }
location = /index.html { return 301 /noexsit; }