2022년 4월 11일 월요일

curl 에서 https hostname 방식으로 접근

 

curl 에서는 가상호스트 등을 테스트 할때 hostname 방식으로 접근할때

HTTP 일땐 --header 에 Host 헤더를 이용하여 호스트 명을 명시해서 가능하나

ex) 

hexcode.example.com 이 호스트명이고 

IP 가 10.101.81.200 이라고 가정할때 

curl --header "Host: hexcode.example.com" http://10.101.81.200


HTTPS 일땐 --header 에 Host 헤더를 이용하기가 어렵다. 

아래와 같이 한다.

ex)

hexcode.example.com 이 호스트명이고 

IP 가 10.101.81.200 이라고 가정할때 

curl --resolve hexcode.example.com:443:10.101.81.200 https://hexcode.example.com


또는 전통적인 방법으로 /etc/hosts 를 수정하여 사용하기도 하자

댓글 없음: