nginx.conf best practices

Best practices for nginx.conf configuration files

Hide server_tokens

Disable the server_tokens HTTP header response to hide the Nginx version your project is running on.

Allow only GET, POST, HEAD HTTP Methods

There are multiple HTTP Methods that are enabled by default. If your project uses only GET, POST and HEAD, you can disable the other methdos such as DELETE, TRACE etc.

Don't use root inside location

In your nginx.conf file, don't use root inside a location {} block directive except when you want to override the location.