iframe 에 페이지가 뜨지 않는 경우 X-Frame-Options
X-Frame-Options
iframe 에 외부 url을 넣을 경우 페이지가 분명 존재함에도 iframe에 표시가되지 않을 때가 있다 이때 크롬개발자 도구를 Console을 보면 아래와 같은 메세지를 확인 할 수 있다.
1 |
Refused to display 'https://example.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'. |
X-Frame-Options 은 숨겨진 링크를 사용자를 속여 클릭하게 만드는 Clickjacking 을 방지하기 위한 옵션으로 X-Frame-Options의 경우 아래와 같이 3가지 옵션이 존재한다.
- DENY
- SAMEORIGIN
- ALLOW-FROM http://example.com/
DENY의 경우 iframe에 페이지를 표시 할 수 없다.
SAMEORIGIN의 경우 같은 도메인을 사용하는 사용하는 페이지만 표시 할 수 있다.
ALLOW-FROM의 경우 지정한 도메인의 페이지만 iframe에 표시할 수 있다.
위 설정은 HTML에서 변경 할수 없고 서버관리자에 의해서 수정될 수 있다.
Ubuntu 16.04 LTS Apache2의 경우
/etc/apache2/conf-available/security.conf 파일을 수정함으로써 변경 또는 사용을 중지할 수 있다.
1 2 3 4 5 |
# Setting this header will prevent other sites from embedding pages from this # site as frames. This defends against clickjacking attacks. # Requires mod_headers to be enabled. # Header set X-Frame-Options: "sameorigin" |
대략 70번째 줄에 위치하고 있으며 쌍따움표안에 값을 변경하면된다 사용하지 않을 경우 Header 앞에 #으로 주석을 걸어 줌으로써 기능을 정지 시킬 수 있다.
자세한 내용은 아래의 링크를 참고
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
RECENT COMMENTS