Preventing public access to .git directory


#1

Hi there, we need to prevent public access to our .git directory on our EE server.

It is suggested that we update our configuration file with the following:

 location ~ path/to/our-repo/.git {
        deny  all;
}

We are however unsure where to place this in our configuration file – would it be in the block for that specific site or as a general rule?

Would this go in /etc/nginx/nginx.conf or in /etc/nginx/sites-available/oursite.com ?

Any help would be greatly appreciated.

Kind regards Francois Wessels


#2
/var/www/domain.com/conf/nginx/anything.conf

That’s the right place for such code.


#3

Thank you @portofacil , ammended as suggested :slight_smile:

Kind regards @francois_wessels


#4