nginx disables access to the setup tutorial for the.git file

  • 2020-05-07 20:54:41
  • OfStack

Now git is very popular and everyone is starting to use it to manage the source code of the website, but the git data directory also has a copy in the root directory of the website, and nginx is usually configured without special treatment to the hidden directory, so that your source files are exposed to the public. To be safe, we need to specifically handle this 1 in the nginx configuration, which is simple. As follows:

Add in server{}


location ~ /\.
{
deny all;
}

or

location ^~ /.git
{
return 444;
}

The contents published by this site are basically the notes recorded when they met before, through the practice of testing. Please feel free to use it. If you have any questions, please leave a message. thank you


Related articles: