Chashitsu

Nginx config - deny .git acces

Nov 5th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 0.54 KB | None | 0 0
  1. # https://stackoverflow.com/questions/2999353/how-do-you-hide-git-project-directories
  2. # This location directive will deny access to any .git directory in any subdirectory.
  3. # Note: This location block must be before your main location block, so that it can be evaluated first.
  4.  
  5. # my config file: /etc/nginx/conf.d/default.conf dont use ../nginx.conf it override your web location path !!!
  6. http {
  7.   server {
  8.     location ~ /\.git {
  9.       deny all;
  10.     }
  11.   }
  12. }
  13.  
  14. # To restart nginx
  15. /etc/init.d/nginx restart
  16. # OR
  17. service nginx restart
Add Comment
Please, Sign In to add comment