Skip to content

Instantly share code, notes, and snippets.

@bean5
Forked from jaxbot/gist:5748513
Created June 7, 2021 15:11
Show Gist options
  • Save bean5/1245ecbb8976099daf5dcc8c2e76e8cd to your computer and use it in GitHub Desktop.
Save bean5/1245ecbb8976099daf5dcc8c2e76e8cd to your computer and use it in GitHub Desktop.
Block nginx from serving .git directories
location ~ /\.git {
deny all;
}
# or, all . directories/files in general (including .htaccess, etc)
location ~ /\. {
deny all;
}
@bean5
Copy link
Author

bean5 commented Jun 7, 2021

Alternative at https://gist.github.com/jaxbot/5748513#gistcomment-3244643:

location ~ /\. {
        deny all;
        return 444;
        access_log off;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment