ELB + EC2 (IIS 8.5)의 IP 제한
목적
IIS에서의 액세스 제한으로 화이트리스트 하려고 할 때 X-Fowarded-For를 참조 할 수없는 것 같은 거동이 있었기 때문에 조사
1. ELB를 통한 IIS에 대한 액세스가 목적
2. SecurityGroup이 아닌 IIS 측에서 액세스 할 수있는 IP를 좁히고 싶었기 때문에
환경
AWS의 EC2 및 ELB를 사용한 환경
아래 그림과 같이 ELB 경유와 직접 액세스를 상정

IP 직접 액세스 (xxx.xxx.xxx.xxx에는 자신의 IP)
ELB 경유 액세스의 2 패턴을 준비(10.1.0.17이나 10.1.0.119는 ELB의 PrivateIP)
OS 정보 등
Windows 2012 R2
IIS 8.5.9600.163884
준비
AWS의 EC2 및 ELB를 사용한 환경
아래 그림과 같이 ELB 경유와 직접 액세스를 상정

IP 직접 액세스 (xxx.xxx.xxx.xxx에는 자신의 IP)
ELB 경유 액세스의 2 패턴을 준비(10.1.0.17이나 10.1.0.119는 ELB의 PrivateIP)
OS 정보 등
Windows 2012 R2
IIS 8.5.9600.163884
준비





AllAllow 설정
AllAllow 전용 (기본값)
당연하지만 액세스할 수 있다. 로그에도 직접 액세스했을 때의 IP와 ELB 경유의 IP가 표시되고 있다
※이하 로그는 xxx.xxx.xxx.xxx를 직접 액세스, 10.1.0.xx를 ELB 경유로 한다
2016-03-25 06:49:30 10.1.0.236 GET / - 80 - xxx.xxx.xxx.xxx - 304 0 0 20
2016-03-25 06:49:33 10.1.0.236 GET / - 80 - 10.1.0.17 - 304 0 0 15
AllAllow로 지정 IP만 Deny 설정

ELB 경유로의 액세스가 가능, IP직접 액세스는 당연히 Deny이기 때문에 액세스 불능
1. IP 직접 액세스

2. ELB 경유

로그상에서도 액세스 거부를 확인할 수 있다
2016-03-25 07:01:31 10.1.0.236 GET / - 80 - xxx.xxx.xxx.xxx - 403 503 5 15
2016-03-25 07:02:18 10.1.0.236 GET / - 80 - 10.1.0.17 - 304 0 0 0
EnableProxyMode 사용
화면 오른쪽 Edit Feature Settings... 에서 지정

방금 액세스 한 ELB를 통한 액세스가 불가능합니다 (ELB를 통해 IP가 10.1.0.119 인 경우 액세스 할 수 없습니다)

X-Forwarded-For를 보고 판별하고 있는가?
2016-03-25 07:06:42 10.1.0.236 GET / - 80 - xxx.xxx.xxx.xxx - 403 503 5 15
2016-03-25 07:07:01 10.1.0.236 GET / - 80 - 10.1.0.119 - 403 503 5 0
X-Forwarded-For를 로그에 추가
로그에 출력해 보고 X-Forwarded-For가 있는지 체크

※Logging에서 Select Fields...에서 추가
로그에 X-Forwarded-For가 부여되었는지 확인
2016-03-25 07:13:19 10.1.0.236 GET / - 80 - 10.1.0.119 - 403 503 5 0 xxx.xxx.xxx.xxx
Deny 설정 해제
IP 직접 지정 Deny 삭제
ELB 경유 · IP 직접 액세스 모두 액세스가 가능한지 확인
2016-03-25 07:16:03 10.1.0.236 GET / - 80 - xxx.xxx.xxx.xxx - 200 0 0 15 -
2016-03-25 07:16:59 10.1.0.236 GET / - 80 - 10.1.0.17 - 200 0 0 16 xxx.xxx.xxx.xxx
AllDeny 설정
Edit IP and Domain Restrictions Settings에서 Access for unspecified clients:에서 Deny 지정

AllDeny 전용
당연히 ELB 경유 · IP 직접 액세스 모두 액세스 불가
1. IP 직접 액세스

2. ELB 경유

로그에서도 액세스가 거부되었는지 확인
2016-03-25 07:18:51 10.1.0.236 GET / - 80 - xxx.xxx.xxx.xxx - 403 503 5 15 -
2016-03-25 07:18:56 10.1.0.236 GET / - 80 - 10.1.0.17 - 403 503 5 0 xxx.xxx.xxx.xxx
AllDeny 상태로 지정 IP로 Allow를 설정
처음에 Deny 설정했을 때의 역의 설정을 실시한다

2016-03-25 06:49:30 10.1.0.236 GET / - 80 - xxx.xxx.xxx.xxx - 304 0 0 20
2016-03-25 06:49:33 10.1.0.236 GET / - 80 - 10.1.0.17 - 304 0 0 15
2016-03-25 07:01:31 10.1.0.236 GET / - 80 - xxx.xxx.xxx.xxx - 403 503 5 15
2016-03-25 07:02:18 10.1.0.236 GET / - 80 - 10.1.0.17 - 304 0 0 0
2016-03-25 07:06:42 10.1.0.236 GET / - 80 - xxx.xxx.xxx.xxx - 403 503 5 15
2016-03-25 07:07:01 10.1.0.236 GET / - 80 - 10.1.0.119 - 403 503 5 0
2016-03-25 07:13:19 10.1.0.236 GET / - 80 - 10.1.0.119 - 403 503 5 0 xxx.xxx.xxx.xxx
2016-03-25 07:16:03 10.1.0.236 GET / - 80 - xxx.xxx.xxx.xxx - 200 0 0 15 -
2016-03-25 07:16:59 10.1.0.236 GET / - 80 - 10.1.0.17 - 200 0 0 16 xxx.xxx.xxx.xxx
Edit IP and Domain Restrictions Settings에서 Access for unspecified clients:에서 Deny 지정

AllDeny 전용
당연히 ELB 경유 · IP 직접 액세스 모두 액세스 불가
1. IP 직접 액세스

2. ELB 경유

로그에서도 액세스가 거부되었는지 확인
2016-03-25 07:18:51 10.1.0.236 GET / - 80 - xxx.xxx.xxx.xxx - 403 503 5 15 -
2016-03-25 07:18:56 10.1.0.236 GET / - 80 - 10.1.0.17 - 403 503 5 0 xxx.xxx.xxx.xxx
AllDeny 상태로 지정 IP로 Allow를 설정
처음에 Deny 설정했을 때의 역의 설정을 실시한다



IP 직접 액세스 가능, ELB를 통해 액세스 할 수 없음 (프록시를 활성화하지 않았기 때문에 X-Forwarded-For 참조하지 않음)
2016-03-25 07:22:47 10.1.0.236 GET / - 80 - xxx.xxx.xxx.xxx - 200 0 0 0 -
2016-03-25 07:23:58 10.1.0.236 GET / - 80 - 10.1.0.119 - 403 503 5 0 xxx.xxx.xxx.xxx
EnableProxyMode 사용
다시 EnableProxyMode 사용



IP 직접 액세스 가능, ELB 경유 액세스 불능
프록시를 활성화해도 X-Forwarded-For를 참조하지 않습니다.
2016-03-25 07:26:54 10.1.0.236 GET / - 80 - xxx.xxx.xxx.xxx - 304 0 0 15 -
2016-03-25 07:26:57 10.1.0.236 GET / - 80 - 10.1.0.17 - 403 503 5 0 xxx.xxx.xxx.xxx
요약
블랙리스트에서의 X-Forwarded-For는 참조하지만 화이트리스트화했을 때의 X-Forwarded-For는 참조하지 않는 거동
Deny는 할 수 있지만 Allow를 할 수없는 것은 어떤 버그인지 자신의 설정 문제인가 ...
Reference
이 문제에 관하여(ELB + EC2 (IIS 8.5)의 IP 제한), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/kt_higa/items/2f100e5fcbf163bf5e36
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
Reference
이 문제에 관하여(ELB + EC2 (IIS 8.5)의 IP 제한), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/kt_higa/items/2f100e5fcbf163bf5e36텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)