'2024/05'에 해당되는 글 1건

  1. 2024.05.03 아파치 웹서버 .git 디렉토리 접근 차단
2024. 5. 3. 23:22

 /.git 폴더가 웹폴더 안에 있었는데... 이게 /.git URL로 접근이 가능하다.

 

그러면, config 파일안에 세팅해놓은 소스 주소나, 비밀번호까지 알 수있다.

 

ㅠㅠ

 

일단 웹서버에서 아파치 폴더로 이동.

 

버전별로 

/etc/httpd/conf

/etc/apache2/conf-enabled

등등이니, 폴더 들어가서 

 

httpd.conf

또는 seccurity.conf 폴더로 들어가서 

아래와 같이 추가하면 된다고 하나... 

<DirectoryMatch "/\.git">
	Require all denied
</DirectoryMatch>

 

이거는 403 Forbidden 이고, 

 

이거보다는 404 Not Found로 처리하는것을 선호한다. 

 

그래서 아래와 같이 쓴다고 하나 (svn, git 등등 다 같이...제한)

RedirectMatch 404 /\\.(svn|git|hg|bzr|cvs)(/|$)

 

난 이거보다는 

VirtualHost를 사용중이라 VirtualHost안에 아래와 같이 추가해주었다.

 

<VirtualHost *:80>
	RewriteRule ^.*\.git.* - [R=404]
</VirtualHost>

 

RewriteRule ^.*\.git.* - [R=404] 이거 한줄만 복사(yy) 해서 host별로 붙여넣기(p) 해주면 편하다.

 

 

 

 

참고 사이트

https://stackoverflow.com/questions/6142437/make-git-directory-web-inaccessible

https://www.lesstif.com/software-architect/apache-httpd-svn-git-23756896.html

https://tom-dlog.tistory.com/entry/LinuxApache2-git-%EB%94%94%EB%A0%89%ED%86%A0%EB%A6%AC-%EC%A0%91%EA%B7%BC-%EC%B0%A8%EB%8B%A8%ED%95%98%EA%B8%B0

 

Posted by Tyson