Prevent GIT folder access in Nginx

To prevent any data leaks I have adjusted the Nginx configuration so that by default it will not serve files inside the .git folders.

Steps to prevent Nginx from serving git folder

vi /etc/nginx/sites-available/default

At the bottom (inside the server block) add:

# Send page not found response when user tries to access git folder
location ~* /\.git/.*$ {
    deny all;
    return 404;