Disallow Access to .git in on the webserver

Disallow Access to .git in on the webserver

To Disallow Access to .git Place this configuration:

For apache in /etc/apache2/apache.conf

  1. <DirectoryMatch "^/.*/\.git/">
  2.   Deny from all
  3. </Directorymatch>

For Nginx in /etc/nginx/nginx.conf

  1. location ~ /\.git {
  2.   return 404;
  3. }


    • Related Articles

    • Nginx : How To Block Exploits, SQL Injections, File Injections, Spam, User Agents, Etc.

      server { [...] ## Block SQL injections set $block_sql_injections 0; if ($query_string ~ "union.*select.*\(") { set $block_sql_injections 1; } if ($query_string ~ "union.*all.*select.*") { set $block_sql_injections 1; } if ($query_string ~ ...
    • Git clone into specific folder

      git init git remote add origin PATH/TO/REPO git fetch git checkout -t origin/master
    • Private Bucket Access Code

      Hello all, It a pleasure to take a small steps towards establishing a good security concerns. It's been mandate now  for every developer to upload and download their precious data from AWS S3 private bucket only. How to access data from Private ...
    • Set Username Password For Git

      https://username:PASSWORD@cloneUrl       ex . https://username:PASSWORD@github.com/Orderhive/orderhive.com.git
    • NGINX : browser caching and gzip compression

      While serving static content from server to browser, if performance is very slow. 1. Enable GZIP compression which will serve files of specified format by zipping it between (server-browser) this minimises web serving time.   2. Enable images caching ...