차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판이전 판
다음 판
이전 판
tech:how_to_hotlink_protect [2012/11/22 13:25] 14.32.18.124tech:how_to_hotlink_protect [2016/07/12 00:56] (현재) – 바깥 편집 127.0.0.1
줄 1: 줄 1:
 +{{tag>hotlink htaccess 핫링크 그림}}
 +======그림 외부 무단 참조 막는 방법 (How To Hotlink Protect; 핫링크 방지)======
 +
 +핫링크란... 다른 사이트나 블로그 같은 것에서 이미지 파일 같은 것을 그대로 따다가 쓰는 것을 말한다. 웹서버 부하는 이곳에 걸리고, 보이는 것은 그쪽처럼 보이니.. 문제가 된다. 
 +
 +=====방패=====
 +.htaccess 에 아래의 것을 상단에 추가하면 된다. 
 +
 +<code>
 +# 그림 외부 참조 막기
 +RewriteEngine on
 +RewriteCond %{HTTP_REFERER} !^$
 +RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?vaslor.net [NC]   #내사이트
 +RewriteCond %{HTTP_REFERER} !^http://(www.)?google.com/.*$ [NC]    #구글봇
 +RewriteCond %{HTTP_REFERER} !search\.naver\.com [NC]               #네이년봇
 +RewriteCond %{HTTP_REFERER} !ws\.daum\.net [NC]                    #다음봇
 +RewriteCond %{HTTP_REFERER} !feedburner\. [NC]                     #피드버너
 +RewriteRule \.(jpg|jpeg|png|gif)$ http://static.naver.net/w9/blank.gif [NC,R,L]
 +</code>
 +
 +이것은 **누가** 그림파일을 요청했는지 [[http_referer]]를 확인하여 
 +vaslor.net과 google.com으로부터의 참조는 허용하고 나머지는 가짜그림을 보여준다. 꼭 네이버로 할 이유는 없다.  http://cfile10.uf.tistory.com/image/2618E03B516F888815E0BC 도 괜찮다.
 +
 +{{image>http://cfile10.uf.tistory.com/image/2618E03B516F888815E0BC}}
 +
 +  * [[http://www.htaccesstools.com/hotlink-protection/|자동제작기 (영문)]]
 +  * [[htaccess]] 참조
 +
 +
 +
 +=====창=====
 + 접속자의 [[http_referer]]를 조사하여 동일 사이트가 아닌 곳에서 접속하면 이를 차단하거나 링크금지 안내문 이미지로 돌리게 된다. 이 것은 비교적 단순한 방법이며 무력화 시키는  위 방법은 방법도 있다.
 +따라서, 이미지를 요청할 때 header에 [[http_referer]]를 해당 사이트 주소로 넣으면 문제 없이 읽어 올 수 있다. 
 +
 +  *      [[http://marcus.tistory.com/36|막힌 이미지 레퍼러를 속여 가져오기...]] 하지만 귀찮을 것임..
 +
 +
 + http://stackoverflow.com/questions/2011083/how-to-download-hotlink-protected-images
 +
 +http://pixabay.com/ko/blog/posts/hotlinking-protection-and-watermarking-for-google-32/
 +
 +====자바====
 +<file java>
 +URL url = new URL("http://www.somesite.com/picture.jpg");
 +
 +URLConnection urlCon = url.openConnection();
 +urlConn.setRequestProperty("Referer", "http://www.somesite.com");
 +urlConn.connect();
 +
 +InputStream urlStream = urlCon.getInputStream();
 +
 +Image image = ImageIO.read(urlStream);
 +</file>
 +
 +====콘솔====
 +  wget --referer=http://www.google.com/ http://www.google.com/intl/en_ALL/images/logo.gif
 +
 +^  누구나 수정하실 수 있다. [[http://vaslor.net/syntax|위키 사용법]] 참고하라. ^
 +