Skip to content

Instantly share code, notes, and snippets.

@jaxbot
Created June 10, 2013 12:58
Show Gist options
  • Save jaxbot/5748513 to your computer and use it in GitHub Desktop.
Save jaxbot/5748513 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;
}
@wwwriks
Copy link

wwwriks commented Dec 3, 2024

Cool!

@melroy89
Copy link

melroy89 commented Dec 4, 2024

I actually have:

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

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