Xeoncross Xeoncross - 3 months ago 10
Git Question

How do you hide .git project directories?

Now that I have nginx setup I need to be able to hide my

.git
directories. What kind of rewrite would I need to stop prying eyes? And where in the
server {}
or
http {}
block would it go?

Answer
http {
  server {
    location ~ /\.git {
      deny all;
    }
  }
}

This location directive will deny access to any .git directory in any subdirectory.

Note: This location block must be before your main location block, so that it can be evaluated first.

Comments