웹&컴퓨팅

다른 곳에서 링크한 이미지 허가하지 않기 - Apache의 SetEnvIf 이용하기

x2chi 2015. 7. 14. 10:58
반응형

레퍼럴이 www.example.com 아닌 사이트에서  /web/images 디렉토리에 접근하는 것을 막는 것입니다.

Prevent "Image Theft"

This example shows how to keep people not on your server from using images on your server as inline-images on their pages. This is not a recommended configuration, but it can work in limited circumstances. We assume that all your images are in a directory called /web/images.

    SetEnvIf Referer "^http://www.example.com/" local_referal
    # Allow browsers that do not send Referer info
    SetEnvIf Referer "^$" local_referal
    <Directory /web/images>
      Order Deny,Allow
      Deny from all
      Allow from env=local_referal
    </Directory>


출처 : http://httpd.apache.org/docs/1.3/mod/mod_setenvif.html#setenvif

 

http://httpd.apache.org/docs/1.3/mod/directive-dict.html#Context

SetEnvIf 에서 사용할 수 있는것은 아래와 같습니다.
Remote_Host - the hostname (if available) of the client making the request
Remote_Addr - the IP address of the client making the request
Request_Method - the name of the method being used (GET, POST, et cetera)
Request_Protocol - the name and version of the protocol with which the request was made (e.g., "HTTP/0.9", "HTTP/1.1", etc.)
Request_URI - the portion of the URL following the scheme and host portion

 

 

 

http://httpd.apache.org/docs/1.3/env.html

 

 

출처 : http://dani.egloos.com/1682729 

반응형