<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hedy Kim on Medium]]></title>
        <description><![CDATA[Stories by Hedy Kim on Medium]]></description>
        <link>https://medium.com/@waltzbucks?source=rss-6dc5cfa66ff------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hIDuRmPatLYvkUi_lFSWYQ.jpeg</url>
            <title>Stories by Hedy Kim on Medium</title>
            <link>https://medium.com/@waltzbucks?source=rss-6dc5cfa66ff------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 09:18:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@waltzbucks/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[고가용성? 내결함성?]]></title>
            <link>https://medium.com/cloudvillains/%EA%B3%A0%EA%B0%80%EC%9A%A9%EC%84%B1-%EB%82%B4%EA%B2%B0%ED%95%A8%EC%84%B1-d3e979d2fb44?source=rss-6dc5cfa66ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3e979d2fb44</guid>
            <dc:creator><![CDATA[Hedy Kim]]></dc:creator>
            <pubDate>Sun, 03 Sep 2023 23:45:34 GMT</pubDate>
            <atom:updated>2023-09-07T01:02:02.305Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A0pbwCHj51z1AGD50nHyMA.jpeg" /><figcaption>photo by <a href="https://medium.com/u/6dc5cfa66ff">Hedy Kim</a></figcaption></figure><p>가끔 “고가용성”, “내결함성” 이 두 단어를 듣게 되면 이해 하고 있다고 생각 되지만, 막상 다른 사람에게 잘 설명하기는 어렵습니다. 이번 글에서는 상대방이 잘 이해할 수 있도록 설명하기 위해서 정리 해둔 내용을 적어 보았습니다.</p><h3>고가용성 (High availability)</h3><h4>영어사전 “Availability”</h4><p>뭔지 알 것 같은데 딱 ‘이거다!’하고 설명하기가 어렵습니다. 우선 가용성이라는 단어의 사전적 의미부터 확인 해보면 무엇인가 가능한 상태를 뜻하고 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*HL47OpU2xbceNuTYKJWzjg.png" /><figcaption>NAVER 사전</figcaption></figure><h4>한글사전 “가용성”</h4><p>“가용성”을 한글사전을 찾아보면 정보통신 사전에서 조금 더 자세하게 정의가 되어 있고 더불어 계산식에 대한 설명을 해주고 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*mvS-2S7o4JItm7JfU9RkiQ.png" /><figcaption>NAVER 사전</figcaption></figure><h4>위키피디아 “Availability”</h4><p>Wikipedia에서 Availability에 대해 자세히 설명 되어 있어 가져왔습니다.</p><p>원문: <a href="https://en.wikipedia.org/wiki/Availability">https://en.wikipedia.org/wiki/Availability</a></p><p>신뢰성 공학에서 가용성이라는 용어는 다음과 같은 의미를 갖습니다.</p><ul><li>시스템, 하위 시스템 또는 장비가 임무 시작 시, 임무가 <strong>알 수 없는, 즉 임의의 시간에 호출될 때 지정된 작동 가능하고 커밋 가능한 상태</strong>에 있는 정도.</li><li>항목이 이상적인 지원 환경에서 명시된 조건에서 사용될 때 주어진 시점에서 <strong>만족스럽게 작동할 확률</strong>입니다.</li></ul><p>일반적으로 고가용성 시스템은 99.98%, 99.999% 또는 99.9996%로 지정될 수 있습니다.</p><p>예를 들면, 예상치 못한 굉장한 트래픽 부하로 응답이 어려운 web에서 어떻게 해서든 응답 처리를 해내고 있을 확률을 말 합니다. 이것이 가용성 인 것입니다. 이러한 가용성의 확률은 다음과 같이 계산할 수 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*-OIrdhO3FtbUas9iX1j8nQ.png" /><figcaption>The simplest representation of <strong>availability</strong> (<em>A</em>) is a ratio of the expected value of the uptime of a system to the aggregate of the expected values of up and down time (that results in the “total amont of time” <em>C</em> of the observation window)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oqZZpru1TkAkKCpDz6tdqQ.png" /><figcaption><a href="https://en.wikipedia.org/wiki/High_availability#Percentage_calculation">https://en.wikipedia.org/wiki/High_availability#Percentage_calculation</a></figcaption></figure><p>위 표에서 보듯이 Availability 의 확률이 높을 수록 정상적으로 응답되지 않을 확률이 굉장히 낮다는 의미가 됩니다. 하지만 Availability의 확률이 높으면 고(High)가용성이 되는 것은 아닙니다. 고가용성(High Availability)에 대해서 <a href="https://en.wikipedia.org/wiki/High_availability">위키피디아</a>에서는 다음과 같이 정의를 하고 있습니다.</p><p>고가용성을 달성하는 데 도움이 될 수 있는 신뢰성 공학의 시스템 설계에는 세 가지 원칙이 있습니다.</p><ol><li><strong>단일 실패 지점 제거</strong>. 즉, 구성 요소의 오류가 전체 시스템의 오류를 의미하지 않도록 시스템에 중복성을 추가하거나 구축하는 것을 의미합니다.</li><li>안정적인 크로스오버. 중복 시스템에서는 <strong>교차 지점 자체가 단일 장애 지점</strong>이 되는 경향이 있습니다. 안정적인 시스템은 안정적인 교차를 제공해야 합니다.</li><li>발생하는 오류 감지. 위의 두 가지 원칙을 준수하면 사용자는 장애를 전혀 볼 수 없지만 <strong>유지 관리 활동</strong>은 반드시 해야 합니다.</li></ol><p>단일 지점을 제거 하는 것에 대해서 강조하고 있습니다. 그리고 AWS의 공식 문서 지침에서도 AWS에서 사용할 수 있는 기능을 사용하여 단일 실패 지점을 없애는 방법에 중점을 둡니다.</p><p>AWS는 강력한 수준의 고가용성을 달성하기 위해 다음 <a href="https://docs.aws.amazon.com/whitepapers/latest/real-time-communication-on-aws/high-availability-and-scalability-on-aws.html">지침</a>을 따를 것을 권장합니다.</p><ul><li><strong>단일 장애 지점이 없도록 시스템을 설계하십시오.</strong> 상태 비저장 및 상태 저장 구성 요소 모두에 대해 자동화된 모니터링, 장애 감지 및 장애 조치 메커니즘 사용</li><li>단일 장애 지점(SPOF)은 일반적으로 <strong>N+1 또는 2N 중복 구성</strong>으로 제거됩니다. 여기서 N+1은 활성-활성 노드 간의 로드 밸런싱을 통해 달성되고 2N은 활성-대기 구성의 노드 쌍에 의해 달성됩니다.</li><li>AWS에는 확장 가능한 <strong>로드 밸런싱 클러스터 또는 활성-대기 쌍</strong> 가정과 같은 두 가지 접근 방식을 통해 HA를 달성하는 몇 가지 방법이 있습니다.</li><li>올바르게 계측하고 시스템 가용성을 테스트합니다.</li><li>장애에 대응, 완화 및 복구하기 위한 수동 메커니즘에 대한 운영 절차를 준비합니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1kaG_4mV4RZ1TiYBbGakaQ.gif" /><figcaption>단일 지점이 제거된 고가용성 구조의 WWW 인스턴스 장애와 RDS의 장애발생 시 장애를 우회하는 구조 설명</figcaption></figure><p>만약 AWS에서 Elastic Load balancer를 만들 때 2개 이상의 Subnet에 위치하도록 하게 된다면, 실제로 endpoint domain에 Lookup IP Address가 subnet의 개수와 동일 하게 생성 된다는 건 이해 하고 있을 겁니다.</p><p>결국 Elastic Load Balacer는 단일 장애 지점이 없도록 구성이 되어졌고, 각 멀티 AZ에서 동일한 중복 리소스를 생성 함으로 써 고가용성을 달성 하게 된다고 봅니다.</p><h3>내결함성 (Fault tolerance)</h3><h4>영어사전 “Tolerance”</h4><p>사전적 의미부터 확인 해보겠습니다. 무엇인가를 절대선이 없이 관대하게 인내하는 뜻을 담고 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*EI8d0m2o8VK-PGKQJsw6yA.png" /><figcaption>NAVER 사전</figcaption></figure><h4>한글사전 “결함성”</h4><p>이번에는 한글로 검색 해보았습니다. 의아하게도 사전에 있을만한 단어인 것 같았는데 막상 사전에서는 검색이 안됩니다. 그나마 가장 유사한 한자어인 “내고장성”으로 검색 해보았습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*37e8gEU2R5jZk7tVnvTaZg.png" /><figcaption>NAVER 사전</figcaption></figure><p>영어, 한글 사전의 의미만 보더라면 일부분에 어떠한 문제가 생겼음에도 정상적으로 동작이 유지되는 형상을 의미 하고 있습니다.</p><h4>위키피디아 “Fault tolerance”</h4><p>위키피디아에는 좀 더 상세하게 정의가 된 내용이 있습니다.</p><p>원문: <a href="https://en.wikipedia.org/wiki/Fault_tolerance#Fault_tolerance_techniques">https://en.wikipedia.org/wiki/Fault_tolerance#Fault_tolerance_techniques</a></p><ul><li>내결함성은 일부 구성 요소 내에서 <strong>하나 이상의 오류가 발생하는 경우에도 시스템이 계속 제대로 작동할 수 있도록 하는 속성</strong>입니다.</li><li>작동 <strong>품질이 조금이라도 저하되면 그 감소는 고장의 심각도에 비례</strong>합니다.</li><li>순진하게 설계된 시스템(naively designed system)은 작은 고장이라도 전체 고장을 일으킬 수 있습니다.</li><li>내결함성은 특히 고가용성, 미션 크리티컬 또는 생명과 직결되는 시스템에서 필요합니다.</li></ul><p>이와 함께 내결함성의 기술에 장애 복구 방식에 대해서도 안내가 되어 있습니다.</p><h4><strong>* 장애복구 방식</strong></h4><ul><li>장애 허용 시스템에서 장애 복구는 롤포워드 복구(roll-forward)와 롤백 복구(roll-back)로 나눌 수 있다.</li><li>시스템 장애로 인해 오류가 일어났을 때 롤 포워드 복구에서는 그 시점의 시스템 상태로 복구를 실시한다.</li><li>롤백 복구에서는 시스템 상태를 약간 이전으로 되돌려(예를 들어, Checkpointing 사용) 거기에서부터 처리를 재개한다.</li><li>롤백 복구에서는 체크 포인트(되돌리는 지점)와 장애 발생 지점과의 사이의 처리는 멱등 (몇 번 실행해도 1회 실행한 것과 같은)이 아니면 안 된다.</li><li>몇 개의 시스템은 오류의 종류나 오류 발생 수에 의해서 롤포워드 복구와 롤백 복구를 구현한다.</li></ul><h4>* 이중화 시스템 (Fault-tolerance by replication)</h4><p>이중화에 의한 장애 허용 시스템은 특징은 세 가지로 나뉜다.</p><ul><li>리플리케이션(Replication)：동일한 시스템을 복수로 준비하여 병렬로 실행시켜 다수를 만족한 올바른 결과를 적용한다.</li><li>다중화(Redundancy) : 동일한 시스템의 복수로 준비하여 장애가 일어나면 보조 시스템으로 전환한다.</li><li>다양화(Diversity)：같은 사양에 다른 하드웨어 시스템을 복수로 준비하여 복제화와 같이 그것을 운용한다. 이 경우, 각 시스템이 똑같은 장애를 일으키지 않는다. (e.g RAID)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QIVZcDr5S_MbHUSdSboupQ.png" /><figcaption>고가용성 구조과 내결함성을 가진 구조의 차이점</figcaption></figure><h3>비유 설명</h3><p>많은 분들이 해당 용어에 대해 학습과 설명 방법에 대해 고민을 많이 할 것입니다. 인터넷에 기술 블로그나 유튜브에서도 가장 많이 비유하는 것이 아마 이것 일 것 입니다.</p><p>원문: <a href="http://www.pbenson.net/2014/02/the-difference-between-fault-tolerance-high-availability-disaster-recovery/">http://www.pbenson.net/2014/02/the-difference-between-fault-tolerance-high-availability-disaster-recovery/</a></p><h4>* 고가용성 (High Availability)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/0*kVwz10w87Ln42z_G.png" /></figure><p>보통은 4개의 바퀴를 사용하는 자동차에 하나의 타이어가 문제가 생겼을 때 상황에 빗대어 설명 하고 있습니다.</p><ul><li>타이어가 펑크가 발생하여 자동차를 멈췄다 → 서비스 일시 중단</li><li>스페어타이어로 교체 → Standby를 서비스로 전환</li><li>다시 자동차를 달린다 → 서비스 복구</li></ul><p>서비스가 일시 중단 되는 과정이 포함되어 있지만 복구 시간이 매우 짧게 되어 99.9999% 이상의 고가용성의 요건이 될 수 있습니다.</p><h4>* 내결함성 (Fault Tolerance)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/0*zv4zeHmwaJtm2xBI.png" /></figure><p>모두가 알겠지만 비행기가 공중에 운항 중일 때는 자동차와 같이 잠시 정차 할 수가 없습니다. 그래서 비행기에 프로펠러가 4개가 존재하고 1개의 프로펠러가 동작하지 않더라도 무사히 비행 운항을 할 수 있다는 점을 내결함성에 빗대어 설명 할 수 있습니다.</p><h4>* 재난복구 (Disaster Recovery)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/0*N7hM_U-MCE_TMZfu.png" /></figure><p>추가로 DR 관련 비유도 있어서 추가 하였습니다. 위 사진은 항공기 조종사(서비스트래픽)가 비행시 운행(서비스)가 불가능 할 때 탈출하여 다른 비행기(DR)로 바꿔서 탑승 할 수 있다는 의미에서 비유 된 이미지 입니다.</p><h3>마무리</h3><p>지금까지 고가용성과 내결함성의 의미를 확인해 보았습니다. 모쪼록 용어를 이해하고 실무와 연결하는데 작게나마 도움이 되셨길 바랍니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3e979d2fb44" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudvillains/%EA%B3%A0%EA%B0%80%EC%9A%A9%EC%84%B1-%EB%82%B4%EA%B2%B0%ED%95%A8%EC%84%B1-d3e979d2fb44">고가용성? 내결함성?</a> was originally published in <a href="https://medium.com/cloudvillains">Cloud Villains</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CloudWatch Agent에서 HTTP Proxy를 통하는 모니터링 방법]]></title>
            <link>https://medium.com/cloudvillains/cloudwatch-agent%EC%97%90%EC%84%9C-http-proxy%EB%A5%BC-%ED%86%B5%ED%95%98%EB%8A%94-%EB%AA%A8%EB%8B%88%ED%84%B0%EB%A7%81-%EB%B0%A9%EB%B2%95-268e7f61c29a?source=rss-6dc5cfa66ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/268e7f61c29a</guid>
            <category><![CDATA[megazonecloud]]></category>
            <category><![CDATA[http-proxy]]></category>
            <category><![CDATA[cloudwatch]]></category>
            <dc:creator><![CDATA[Hedy Kim]]></dc:creator>
            <pubDate>Tue, 08 Aug 2023 01:18:31 GMT</pubDate>
            <atom:updated>2023-09-03T23:48:01.700Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IYrs6gkkYsCswYC7GMvsHA.jpeg" /><figcaption>Han-gang River at dawn photo by <a href="https://medium.com/u/6dc5cfa66ff">Hedy Kim</a></figcaption></figure><p>Hybrid architecture에서 DX(AWS Direct Connect)로 연결된 On-prem의 Private network 환경의 시스템을 CloudWatch Agent를 이용하여 AWS CloudWatch로 모니터링시에 다음과 같은 시도를 해볼 수 있습니다.</p><h4>Case1</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ervAeX8xkm0rWJ-XRyqSeQ.png" /></figure><p>CloudWatch Agent가 설치된 시스템 또는 내부 DNS관리 시스템에서 monitoring.amazonaws.com에 대한 IP Address를 강제로 DX 또는 VPN으로 연결된 VPC내 CloudWatch VPC Endpoint의 ENI IP Address로 강제하는 방법이 있습니다.</p><p>해당 방법은 내부 DNS시스템이 없을 경우 전체 시스템내에 local resolve 설정을 관리 해야하는 번거로움이 발생 할 수 있습니다.</p><h4>Case2</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IF9JOERrPbAG5owWOeD24A.png" /></figure><p>CloudWatch Agent에 Proxy target설정으로 별도 Proxy server를 통하여 monitoring.amazonaws.com의 VPC Endpoint로 reporting 하는 방법이 있습니다.</p><p>이 방법은 내부망에서만 접근 가능한 EC2 Server를 최소 한대만 이용하여 구성이 가능하다는 이점이 있습니다.</p><p>이번 포스트에서는 <strong>Case2</strong>에서 언급한 Proxy server를 통해 CloudWatch Agent에서 monitoring.amazonaws.com으로 전달 하는 방식에 대해서 살펴보겠습니다.</p><h3>CloudWatch Agent configuration for proxy</h3><p>CloudWatch Agent 설치 후 common-config.toml 파일에서 proxy 설정을 진행 합니다. 참고로 시스템내에 http_proxy , https_proxy환경변수로 설정할 경우에도 Agent에서 proxy설정으로 인식 합니다.</p><pre>[proxy]<br>   http_proxy = &quot;http://{PROXY_SERVER_ADDRESS}:{PROXY_SERVER_PORT}&quot;<br>   https_proxy = &quot;http://{PROXY_SERVER_ADDRESS}:{PROXY_SERVER_PORT}&quot;</pre><p><em>Guide document<br></em><a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-commandline-fleet.html#CloudWatch-Agent-profile-instance-first"><em>https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-commandline-fleet.html#CloudWatch-Agent-profile-instance-first</em></a></p><h3>CloudWatch Agent Proxy mode behavior</h3><p>CloudWatch Agent에서는 Proxy를 통하여 Endpoint domain monitoring.amazonaws.com을 그대로 사용하여 reporting 하는 경우 다음과 같은 동작을 하게 됩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w7WveOlz_xfKnCL4Idj_TQ.png" /></figure><ol><li>HTTP <strong>CONNECT</strong> method로 Proxy server와 tunnel을 요청과 함께 monitoring.amazonaws.com로 TCP 연결을 요청합니다.</li><li>Proxy server는 <strong>CONNECT</strong> method 요청의 Forward target URL 대상지와 연결(Establish)을 맺습니다. 이후 CloudWatch Agent에게 준비되었다는 의미로 200 OK응답을 전달 합니다.</li><li>CloudWatch Agent는 앞서 연결한 Proxy tunnel을 통해 HTTPS로 POST method 요청(request)을 전송하게 됩니다.</li><li>전송이 완료 되면 서버 설정에 따라 Proxy tunnel을 종료 하거나 재사용 합니다.</li></ol><h3>HTTP CONNECT method</h3><p>HTTP tunneling의 가장 일반적인 형태로 표준화된 HTTP CONNECT method를 사용합니다. HTTP CONNECT method는 <a href="https://datatracker.ietf.org/doc/html/rfc2616#section-9.9">RFC-2616 HTTP/1.1</a>에서 정의 되었습니다.</p><p>위와 CloudWatch Agent에서 Proxy mode 사용하는 것 처럼 Client는 CONNECT method 메커니즘에서 Proxy server에 TCP 연결을 원하는 대상으로 전달하도록 요청합니다. <br>그런 다음 Proxy server는 클라이언트를 대신하여 연결을 진행합니다. <br>서버에서 연결이 설정되면 프록시 서버는 계속해서 클라이언트와 TCP 스트림을 프록시합니다.</p><p>초기 연결 요청만 HTTP이며, 그 후 서버는 단순히 설정된 TCP 연결을 프록시합니다.</p><h3>Forward proxy setup</h3><p>이번 테스트에서 사용된 Proxy server application은 <strong>Nginx</strong> 입니다.</p><p>다만 Nginx는 Forward proxy용도로 디자인하지 않았습니다. 그렇기 때문에 nginx.org에서 제공하는 패키지들은 기본적으로 ssl forward가 제공되는 모듈이 없습니다.</p><p>하지만 github에 공개되어 있는 <a href="https://github.com/chobits/ngx_http_proxy_connect_module.git">ngx_http_proxy_connect_module</a>를 사용하여 구현이 가능합니다. 해당 nginx module과 함께 빌드 및 설치 방법은 아래 링크 참고 부탁 드립니다.</p><p><a href="https://github.com/chobits/ngx_http_proxy_connect_module#install">https://github.com/chobits/ngx_http_proxy_connect_module#install</a></p><h3>nginx config file 수정</h3><pre>vi /usr/local/nginx/conf/nginx.conf</pre><p>httpcontext 블록에 아래와 같이 server context를 추가 합니다.</p><ul><li>Listen port는 8080 입니다.</li><li>proxy_connect_allow 는 80,443 입니다. 이 설정은 외부로 요청할 주소지의 대상 포트 범위 입니다.</li><li>요청된 외부 연결시 지연 대기시간 설정인proxy_connect_connect_timeout와 전송 대기시간 proxy_connect_data_timeout 모두 60초로 설정 하였습니다.</li><li>location 은 모든 요청에서 대상으로 요청받은 URL을 그대로 외부로 다시 요청 하도록 설정 하였습니다.</li></ul><pre>server {<br>  listen  8080;<br>  <br>  access_log /var/log/nginx/access.log combined;<br>  <br>  # dns resolver used by forward proxying<br>  # TODO: Need to check up .2 resolver address on VPC network environment<br>  resolver  10.0.0.2;<br>  <br>  # forward proxy for CONNECT request<br>  proxy_connect;<br>  <br>  # Syntax: proxy_connect_allow all | [port ...] | [port-range ...]<br>  # This directive specifies a list of port numbers or ranges to which the proxy CONNECT method may connect.<br>  # By default, only the default https port (443) and the default snews port (563) are enabled.<br>        # Using this directive will override this default and allow connections to the listed ports only.<br>  proxy_connect_allow            80 443;<br>  <br>  # Defines a timeout for establishing a connection with a proxied server.<br>  proxy_connect_connect_timeout  60s;<br>  <br>  # Sets the timeout between two successive read or write operations on client or proxied server connections.<br>  # If no data is transmitted within this time, the connection is closed.<br>  proxy_connect_data_timeout     60s;<br>  <br>  # forward proxy for non-CONNECT request<br>  location / {<br>   proxy_pass $scheme://$host$request_uri;<br>   proxy_set_header Host $host;<br>  }<br>}</pre><h4>NGINX restart</h4><p>수정된 설정을 반영하기 위해 Nginx 데몬을 재시작 합니다</p><pre>systemctl restart nginx.service</pre><h3>HTTP Proxy test</h3><p>curl을 사용하여 proxy 서버로 tunnel 연결 및 HTTPS 요청을 하여 응답여부를 체크 해볼 수 있습니다.</p><pre>curl -sv --proxytunnel --proxy http://{PROXY_SERVER_IP}:8080 https://monitoring.ap-northeast-2.amazonaws.com/</pre><p>Proxy를 통하여 CloudWatch endpoint로 요청이 전달되는지 여부를 확인 하기 위한 테스트 이기 때문에, 해당 커맨드 테스트 결과는 <strong>404 Not Found</strong>로 &lt;UnknownOperationException/&gt; 응답이 확인 되었다면, Forward proxy는 정상 동작 하는 것 입니다.</p><p>도움이 되셨길 바랍니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=268e7f61c29a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudvillains/cloudwatch-agent%EC%97%90%EC%84%9C-http-proxy%EB%A5%BC-%ED%86%B5%ED%95%98%EB%8A%94-%EB%AA%A8%EB%8B%88%ED%84%B0%EB%A7%81-%EB%B0%A9%EB%B2%95-268e7f61c29a">CloudWatch Agent에서 HTTP Proxy를 통하는 모니터링 방법</a> was originally published in <a href="https://medium.com/cloudvillains">Cloud Villains</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RFC-9111 HTTP Caching 무엇이 바뀌었나?]]></title>
            <link>https://medium.com/cloudvillains/rfc-9111-http-caching-%EB%AC%B4%EC%97%87%EC%9D%B4-%EB%B0%94%EB%80%8C%EC%97%88%EB%82%98-11cbece93f9a?source=rss-6dc5cfa66ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/11cbece93f9a</guid>
            <category><![CDATA[rfc9111]]></category>
            <category><![CDATA[cdn]]></category>
            <category><![CDATA[cloudfront]]></category>
            <category><![CDATA[http-cache]]></category>
            <dc:creator><![CDATA[Hedy Kim]]></dc:creator>
            <pubDate>Thu, 06 Jul 2023 00:38:31 GMT</pubDate>
            <atom:updated>2023-07-06T00:38:31.303Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f2Pk6Ic1DSAiNtQOR8OmFg.jpeg" /><figcaption>Yosemite valley morning photo by <a href="https://medium.com/u/6dc5cfa66ff">Hedy Kim</a></figcaption></figure><p>AWS CloudFront는 CDN 서비스이고 Cache를 해주고 있다고 대부분 이해 하고 있을 것 입니다.</p><p>CDN 서비스의 가장 핵심이 되는 HTTP Caching에 대한 구현도 중요하며 모던브라우저들에서는 CDN으로 부터 받는 응답 또한 RFC에 등록되어 있는 HTTP Protocol에 관련된 모든 표준에 따라 처리되게 구현되어야 합니다.</p><p>이렇게 보내는 쪽과 받는 쪽 모두 신뢰성 있는 컨텐츠를 요청하고 받을 수 있는 것은 합의된 HTTP Protocol을 따르고 있기 때문입니다.</p><p>아래 타임라인으로 보게 되면 2000년대에 들어서 HTTP Protocol의 업데이트가 이전보다 빨라지고 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N6QVcmOD61ht3_JodhSrVg.png" /></figure><p>2000년대 부터 인터넷 사용자가 전세계적으로 급격하게 늘어남과 동시에 모바일기기의 발전이 가속화 되었습니다. 이로 인해 인터넷상의 사용자 트래픽은 이전보다 다양하고 복잡한 조건과 요구사항을 가지게 되었습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y3pEiJa6Ax9fn0VsxjnyZw.png" /><figcaption><a href="https://ourworldindata.org/">https://ourworldindata.org/</a></figcaption></figure><p>특히 여러 위험으로부터 사용자의 보호를 위해 다양한 Draft 문서가 등록되고 있기 때문에 업데이트가 빨라지는 경향이 보입니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X06nUg2mdQuhmE11qEHGaQ.png" /><figcaption><a href="https://www.rfc-editor.org/rfcs-per-year/">https://www.rfc-editor.org/rfcs-per-year/</a></figcaption></figure><h3>RFC (Request for comments)가 뭐에요?</h3><p>IETF(Internet Engineering Task Force)는 1986년에 설립된 최고의 인터넷 표준 개발 조직(SDO)입니다. 이곳에서 기술 문서를 RFC로 게시하고 있습니다. RFC는 역사적 제목인 *Requests for Comments*의 약어입니다. RFC는 1969년에 게시된 RFC 1부터 시작하여 순차적으로 번호가 매겨집니다(RFC 시리즈는 IETF보다 앞서 있음). 각 RFC에는 일반적으로 ‘인터넷 표준’, ‘제안된 표준’, ‘정보용’, ‘실험용’ 또는 ‘역사적’ 중 하나의 상태가 있습니다. 일부 상태는 시간이 지남에 따라 변경될 수 있습니다. RFC는 자유롭게 사용할 수 있습니다.</p><p>다만 RFC가 게시되면 수정되지 않습니다. 설명하는 사양이 변경되면 표준은 첫 번째를 “구식화”하는 다른 RFC에 다시 게시됩니다. RFC에서 기술적 또는 편집상의 오류가 발견되면 정오표가 RFC에 연결되거나 다음 문서 업데이트를 위해 보류될 수 있습니다.</p><p>좀 더 자세히 설명이 잘 되어 있는 링크를 남겨 두겠습니다.</p><p><a href="https://en.wikipedia.org/wiki/Request_for_Comments">https://en.wikipedia.org/wiki/Request_for_Comments</a> — <em>Wikipedia Request for Comments</em></p><p><a href="https://net-study.club/entry/RFC-Request-for-Comments%EB%9E%80-RFC%EC%9D%98-%EC%97%AD%EC%82%AC-RFC-%EC%A2%85%EB%A5%98-RFC-%ED%91%9C%EC%A4%80%ED%99%94-%EC%A0%88%EC%B0%A8">RFC(Request for Comments)란? RFC의 역사, RFC 종류, RFC 표준화 절차</a> — <em>net-study.club</em></p><p><a href="https://www.lesstif.com/software-architect/rfc-request-for-comments-129007717.html">RFC(Request for Comments) 란?</a> — <em>lesstif.com</em></p><h3>RFC-9111 HTTP Caching</h3><p>이번에 살펴볼 RFC-9111은 기존 RFC-7234가 업데이트된 문서입니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CUbYY5pzKsA1-5wKiJhd-w.png" /><figcaption><a href="https://datatracker.ietf.org/doc/rfc9111/">https://datatracker.ietf.org/doc/rfc9111/</a></figcaption></figure><p>2015년에 QUIC가 Draft가 되어 많은 관심을 받았고, HTTP 프로토콜에 관련된 제안 문서 중 HTTP Caching문서는 2016년 7월에 Draft되기 시작하여 수정 되어 왔습니다. 최종적으로 RFC-9111로 2022년 6월에 릴리즈 되었습니다.</p><p>기존 RF-7234 HTTP/1.1 Caching 문서에서 RFC-9111로 주요 변경된 세션은 7개로 이것에 대해 살펴 보겠습니다.</p><p>상세한 내용은 RFC-9111(<a href="https://www.rfc-editor.org/rfc/rfc9111.html">링크</a>)에서 보실수 있습니다.</p><h4>1. Calculating Freshness Lifetime (Session 4.2.1) - updated</h4><blockquote><em>Handling of duplicate and conflicting cache directives has been clarified. (</em><a href="https://www.rfc-editor.org/rfc/rfc9111.html#calculating.freshness.lifetime"><em>Section 4.2.1</em></a><em>)</em></blockquote><p>Cache된 객체에 대한 응답되는 헤더값 중 중복되거나 충돌되는 지시자에 대해서 좀 더 명확한 가이드가 업데이트 되었습니다.</p><p>가장 아래 마지막 구문과 같이 max-age 와 no-cache 가 혼용되어서 응답될 경우에 가장 제한 적인 지시자(no-cache를 의미 하는 것으로 보임)를 따라야 한다라고 좀더 명확하게 안내하고 있습니다.</p><h4>2. Invalidating Stored Responses (Session 4.4) - updated</h4><blockquote><em>Cache invalidation of the URIs in the Location and Content-Location header fields is no longer required but is still allowed. (</em><a href="https://www.rfc-editor.org/rfc/rfc9111.html#invalidation"><em>Section 4.4</em></a><em>)</em></blockquote><blockquote><em>Cache invalidation of the URIs in the Location and Content-Location header fields is disallowed when the origin is different; previously, it was the host. (</em><a href="https://www.rfc-editor.org/rfc/rfc9111.html#invalidation"><em>Section 4.4</em></a><em>)</em></blockquote><p>무효화 요청시 캐시컨텐츠의 응답코드 2xx 또는 3xx일 경우 가능하며, 특히 location, content-location 헤더 필드가 포함되어 있을 경우 해당 경로로 validation 요청을 트리거 할수 있었습니다.</p><p>좀더 구체적인 제안으로 무효화할 URI의 출처 Origin과 URI가 다른경우 무조건 무효화를 트리거 하면 안된다고 명시 되어 있으며, 여기서 기존 RFC-7234에서 host라는 명칭 대신 RFC-9111 에서는 Origin으로 명칭이 변경 되었습니다.</p><h4>3. Age (Session 5.1) - updated</h4><blockquote><em>Handling invalid and multiple Age header field values has been clarified. (</em><a href="https://www.rfc-editor.org/rfc/rfc9111.html#field.age"><em>Section 5.1</em></a><em>)</em></blockquote><p>Age헤더의 필드 값에 대해 이전보다 좀더 구체적으로 제약 사항들이 명시 되었습니다.</p><ul><li>하나의 개체만 가지는 헤더 필드로 정의되어 있지만 목록 기반 Age 필드 값이 있는 메시지를 응답받게 된다면, 캐시는 필드 값의 첫 번째 멤버를 사용하고 후속 값은 버려야 합니다.</li><li>위에 이어 음수가 아닌 정수 이외의 것을 포함하는 경우에 캐시는 해당 필드를 무시해야 합니다. <strong>(SHOULD)</strong></li></ul><h4>4. Cache-Control (Session 5.2) - updated</h4><blockquote><em>Some cache directives defined by this specification now have stronger prohibitions against generating the quoted form of their values, since this has been found to create interoperability problems. Consumers of extension cache directives are no longer required to accept both token and quoted-string forms, but they still need to parse them properly for unknown extensions. (</em><a href="https://www.rfc-editor.org/rfc/rfc9111.html#field.cache-control"><em>Section 5.2</em></a><em>)</em></blockquote><p>HTTP Caching에서 가장 중요한 헤더 필드일 것입니다. RFC-7234에서 정의된 cache-control 헤더의 일부 지시문(directives)들에 대해 좀더 명확하게 설명을 추가하였습니다.</p><p>그리고, 정의된 캐시 지시자를 재생성 하는 것을 강력하게 제한하여 End-user 간의 상호 운용성에 혼란을 일으키기는 것을 방지하도록 추가 되었습니다.</p><p>확장 캐시 지시자(5.2.3. Extension Directives) 에서는 애플리케이션에서 알수 없는 확장에 대해 적절하게 구문 분석을 통해 캐시에 영향이 없이 모두 수락 하지 않도록 구현 되도록 고려해야 할 사항들에 대해 업데이트 되었습니다.</p><h4>5. Response Directives (Session 5.2.2) - updated</h4><blockquote><em>The public and private cache directives were clarified, so that they do not make responses reusable under any condition. (</em><a href="https://www.rfc-editor.org/rfc/rfc9111.html#cache-response-directive"><em>Section 5.2.2</em></a><em>)</em></blockquote><p>응답 지시자 Public과 Private 에 대해서 좀더 명확하게 업데이트 되었습니다. 특히 Private 지시자의 경우 어떤 경우에도 재사용을 금지 하도록 명시하고 있습니다.</p><h4>6. must-understand (Session 5.2.2.3) - new</h4><blockquote><em>The must-understand cache directive was introduced; caches are no longer required to understand the semantics of new response status codes unless it is present. (</em><a href="https://www.rfc-editor.org/rfc/rfc9111.html#cache-response-directive.must-understand"><em>Section 5.2.2.3</em></a><em>)</em></blockquote><p>새로운 Cache-Control response 지시자 입니다. 206 Partial Content 또는 304 Not Modified 상태 코드응답이나 must-understand지시자가 있는 경우 캐싱 요구 사항을 이해하는 경우에만 응답을 저장해야 함을 나타냅니다.</p><p>만약 must-understand가 지원되지 않는경우 fallback을 위해 no-store와 결합되어 응답되어야 합니다.</p><p>Cache-Control: must-understand, no-store</p><p>예시를 들면,</p><ul><li>캐시가 must-understand를 지원하지 않으면 무시됩니다. 그리고 no-store도 있으면 응답이 저장되지 않습니다.</li><li>캐시가 must-understand를 지원하는 경우 상태 코드를 기반으로 캐시 요구 사항(<a href="https://www.rfc-editor.org/rfc/rfc9111.html#name-storing-responses-in-caches">Session 3</a>) 을 이해하여 응답을 저장합니다.</li></ul><h4>7. Warning (Session 5.5) - obsoleted</h4><blockquote><em>The Warning response header was obsoleted. Much of the information supported by Warning could be gleaned by examining the response, and the remaining information — although potentially useful — was entirely advisory. In practice, Warning was not added by caches or intermediaries. (</em><a href="https://www.rfc-editor.org/rfc/rfc9111.html#field.warning"><em>Section 5.5</em></a><em>)</em></blockquote><p>캐시는 캐시된 객체에 대한 유효성에 관련된 정보를 전달하는 용도로 Warning헤더를 전달 해줄 수 있었습니다. 이 헤더의 정보에 따라 오래된 캐시인지, 재검증 상태에 대해서 전달 받을수 있었습니다.</p><p>하지만 이 헤더가 폐기(obsoleted)된 이유는, 대부분 중계자(intermediaries = 아마 CDN Provider or Proxy)에서 응답시 사용되고 있지 않고 있습니다. 그리고 여러 다른 헤더와 Cache-Control 헤더의 지시자를 통해 충분히 정보를 얻을 수 있습니다. 대표적인 예로 Age 헤더와 Cache-Control 지시자인 stale-while-revalidate 입니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*DYV3cmluFYfynK1g.png" /></figure><p>지난 2023년 5월 AWS CloudFront에 Cache-Control 헤더의 지시자 stale-while-revalidate와 stale-if-error를 서포트 한다고 공식 발표 하였습니다.</p><blockquote>Amazon CloudFront now supports stale-while-revalidate and stale-if-error cache control directives <br><a href="https://aws.amazon.com/ko/about-aws/whats-new/2023/05/amazon-cloudfront-stale-while-revalidate-stale-if-error-cache-control-directives/">https://aws.amazon.com/ko/about-aws/whats-new/2023/05/amazon-cloudfront-stale-while-revalidate-stale-if-error-cache-control-directives/</a></blockquote><p>Warning 헤더대신 캐시된 객체의 유효성에 대한 정보를 얻을 수 있습니다.</p><p>도움이 되셨으면 좋겠습니다.</p><p>Fin.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11cbece93f9a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudvillains/rfc-9111-http-caching-%EB%AC%B4%EC%97%87%EC%9D%B4-%EB%B0%94%EB%80%8C%EC%97%88%EB%82%98-11cbece93f9a">RFC-9111 HTTP Caching 무엇이 바뀌었나?</a> was originally published in <a href="https://medium.com/cloudvillains">Cloud Villains</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amazon CloudFront: Brotli, Gzip 동시 사용시 cache 에 대한 동작]]></title>
            <link>https://medium.com/cloudvillains/amazon-cloudfront-brotli-gzip-%EB%8F%99%EC%8B%9C-%EC%82%AC%EC%9A%A9%EC%8B%9C-cache-%EC%97%90-%EB%8C%80%ED%95%9C-%EB%8F%99%EC%9E%91-2cecc49874ac?source=rss-6dc5cfa66ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/2cecc49874ac</guid>
            <category><![CDATA[gzip]]></category>
            <category><![CDATA[cloudfront]]></category>
            <category><![CDATA[cdn-service]]></category>
            <category><![CDATA[brotli]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Hedy Kim]]></dc:creator>
            <pubDate>Wed, 27 Oct 2021 10:54:21 GMT</pubDate>
            <atom:updated>2024-04-28T23:39:55.240Z</atom:updated>
            <content:encoded><![CDATA[<h3>Amazon CloudFront: Brotli, Gzip 동시 사용시 cache에 대한 동작 탐구</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dSUVACQn82enxQRjleiuLA.jpeg" /></figure><p>2020년 9월 10일부터 AWS CloudFront에 Brotli 지원을 시작하며 Gzip과 Brotli 두 가지 압축 포멧을 동시에 이용 할 수 있게 되었습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*isK9_oLaHpZK5JSviv25_A.png" /><figcaption><a href="https://awsapichanges.info/archive/changes/3c7f12-cloudfront.html">https://awsapichanges.info/archive/changes/3c7f12-cloudfront.html</a></figcaption></figure><p>Gzip과 Brotli 두 압축 포멧에 대한 비교 자료는 간단한 검색으로 다양하게 찾아보실 수 있습니다. 이번 포스트에서는 CloudFront에서 이 두가지 압축 포멧을 사용할 때 캐시 처리가 어떻게 되고, 어떻게 응답하는지 확인해 보도록 하겠습니다.</p><h3>제약사항</h3><p>우선 CloudFront 압축기능 사용에 대한 제약 사항을 확인 해보겠습니다.</p><ul><li>특정 Content-Type에 대해서만 압축을 지원 (<a href="https://docs.aws.amazon.com/ko_kr/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-cloudfront-file-types">Link</a>)</li><li>1,000 ~ 10,000,000 bytes에 대해서만 압축을 지원</li><li>Origin 응답으로 부터 <em>Content-Length 헤더가 빠진 경우</em> 압축하지 않음</li><li>압축 기능 활성화시에 이미 엣지 로케이션에 캐시되어 있는 객체 대해서는 다시 압축 하지 않음</li><li>Origin에서 압축을 지원 하는 경우 동작 안함</li><li>HTTP/1.0 압축 지원 제외</li></ul><p>위 제약 사항 중 두가지에 대해서 좀 더 이해를 해보겠습니다.</p><p><strong>Content-Length 헤더가 없는 경우</strong></p><ul><li>Content-Length 개체 헤더는 수신자에게 보내지는, 바이트 단위를 가지는 개체 본문의 크기를 나타며, CloudFront에서는 압축 대상의 크기를 알아야지만 압축 지원여부를 체크하게 됩니다.</li><li>Origin server 측에서 압축 buffer size가 넘는 크기이거나, 동적인 객체인 경우 “Transfer-Encoding: chunked”로 응답되게 되어 압축을 지원 할 수 없게됩니다.</li></ul><p><strong>이미 엣지 로케이션에 캐시되어 있는 객체 대해서는 다시 압축 하지 않음</strong></p><ul><li>압축기능 활성화 하게 되면 CloudFront의 응답 헤더에 “Vary: Accept-Encoding”이 붙어서 오게 됩니다. 이 뜻은 Accept-Encoding 헤더를 Cache-key로 사용된다는 의미이며, 기존 캐시와 구분되어 지기 때문에 별도로 캐시하게 됩니다.</li><li>즉, 기능 활성화 이전의 기존 캐시에 대해서는 영향을 주지 않습니다.</li></ul><h3>유형별 CloudFront Cache 동작</h3><p>여기서 부터는 Gzip, Brotli 각각 설정 그리고 두 포멧 모두 설정시 동작을 살펴 보겠습니다.</p><h4><strong>Case#1</strong></h4><ul><li>Origin은 Gzip 압축 지원하지 않음</li><li>CloudFront Gzip 압축 설정</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*ud_KkN-pc6lcIEKEASib7w.png" /></figure><p>위와 같이 CloudFront에서 “Accept-Encoding: gzip”으로 요청하였음에도 Origin 응답은 gzip이 아니지만, content의 타입과 크기가 적절하다면(위 제약사항 참고) gzip 압축을 해주게 됩니다.</p><h4>Case#2</h4><ul><li>Origin은 Gzip 압축 지원</li><li>CloudFront Gzip 압축 설정</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1TxFokRdiJLuhmoVvDfwxQ.png" /></figure><p>CloudFront에서 압축을 지원을 하고 있지만, Origin에서 이미 gzip content를 응답해 준다면 추가 압축처리 없이 그대로 Cache하여 Client에게 전달 됩니다.</p><blockquote>위 두 Case는 Brotli 만 활성화하고 Origin에서 Brotli support여부에 따라 동일하다고 이해 가능 합니다.</blockquote><h4>Case#3</h4><ul><li>Origin은 Brotli, Gzip 모두 지원</li><li>CloudFront Brotli, Gzip 압축 설정</li></ul><p>Step#1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*7Ic3pqgtz2gUXsSbrgk9fA.png" /></figure><p>우선 같은 content에 대해 gzip 요청으로 인하여 gzip content가 “Accept-Encoding: gzip” 헤더를 Cache key로 가지고 CloudFront에 Cache가 됩니다.</p><p>Step#2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*IF4P69qffgAKU2jaEWUKrw.png" /></figure><p>이번에는 Client로 부터 “Accept-Encoding: br, gzip” 요청이 유입 됩니다. 이에 앞서 Cache 되어 있는 gzip content를 받게 됩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*U02b8nqq0A2AGtcB.jpg" /></figure><blockquote><strong>어? Brotli가 우선 지원 아니였나요?</strong></blockquote><blockquote>최종 사용자가 두 형식을 모두 지원하는 경우, CloudFront는 Brotli를 사용합니다. <a href="https://docs.aws.amazon.com/ko_kr/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html">https://docs.aws.amazon.com/ko_kr/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html</a></blockquote><p>음.. 일단 계속 진행 합니다.</p><p>Step#3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*w2v8nmTM53GN0n1zEZbkwQ.png" /></figure><p>이번에는 Client로 부터 “Accept-Encoding: br” 요청이 유입 됩니다. 이에 앞서 “Accept-Encoding: br” Cache key로 Cache가 없어 Origin으로 부터 새로 응답받아와 br content를 전달 합니다.</p><h3>그런데..</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*4ck0ZPE6H-gzGO95.jpg" /></figure><p>Case#3의 Step#2와 같이 “Accept-Encoding: br, gzip” 요청 했음에도 분명 brotli가 우선이라고 되어 있는데 Cache 되어 있는 gzip을 주는 걸까요?</p><p>정답은<strong> </strong><a href="https://docs.aws.amazon.com/ko_kr/AmazonCloudFront/latest/DeveloperGuide/controlling-the-cache-key.html#cache-key-understand-cache-policy-settings"><strong>“캐시 키 제어” 문서</strong></a>에서 확인 할 수 있었습니다.</p><blockquote>두 압축 형식에 대해 압축된 객체 캐싱이 활성화된 경우, <br>엣지 로케이션에 <strong>요청과 일치하고 만료되지 않은 Brotli 또는 Gzip 압축 객체</strong>가 있는 경우 엣지 로케이션에서 최종 사용자에게 객체를 반환합니다.</blockquote><p>이 동작으로 인해 Cache hit rate를 높게 유지 할 수 있을거라고 합니다. <br>결국은 Client의 “Accept-Encoding” 헤더를 무조건 Cache key로 사용 하는 것은 아니라고 보입니다.</p><p>도움이 되셨으면 좋겠습니다.</p><p>Fin.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2cecc49874ac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudvillains/amazon-cloudfront-brotli-gzip-%EB%8F%99%EC%8B%9C-%EC%82%AC%EC%9A%A9%EC%8B%9C-cache-%EC%97%90-%EB%8C%80%ED%95%9C-%EB%8F%99%EC%9E%91-2cecc49874ac">Amazon CloudFront: Brotli, Gzip 동시 사용시 cache 에 대한 동작</a> was originally published in <a href="https://medium.com/cloudvillains">Cloud Villains</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amazon CloudFront: 502 Bad Gateway시 Origin SSL 인증서 설정에 대하여]]></title>
            <link>https://medium.com/cloudvillains/amazon-cloudfront-502-bad-gateway%EC%8B%9C-origin-ssl-%EC%9D%B8%EC%A6%9D%EC%84%9C-%EC%84%A4%EC%A0%95%EC%97%90-%EB%8C%80%ED%95%98%EC%97%AC-a5c422ceffed?source=rss-6dc5cfa66ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5c422ceffed</guid>
            <category><![CDATA[502]]></category>
            <category><![CDATA[cloudfront]]></category>
            <category><![CDATA[ssl]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Hedy Kim]]></dc:creator>
            <pubDate>Thu, 24 Jun 2021 15:44:24 GMT</pubDate>
            <atom:updated>2024-04-28T23:39:08.898Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qzvhjNZchefCp3Pu_xVqRQ.png" /></figure><blockquote>⚠️ 2021. 6. 25 업데이트<br>이번 포스트 작성하던 시기에는 테스트 결과를 TCP패킷으로 전부 확인 했었습니다. 글이 올라가고 난 뒤에 몇몇 질문을 받게 되어 재검증을 위해 동일한 환경으로 다시 테스트한 결과가 포스트 내용과 달라 업데이트 하였습니다. <br>현재는 글을 작성하던 시기와는 다르게, 현재 가이드와 같이 Origin Domain Name 또는 Host 중 하나라도 Origin의 SSL 인증서와 일치하면 문제가 생기지 않습니다.</blockquote><h3>비오던 어느날..</h3><p>CloudFront에서 Origin으로 SSL Handshake를 어떻게 하고 있을까? 라는 생각에 Origin request 동작을 들여다 보게 되었습니다. 그러던 중 인증서가 맞게 설정되어 있는데도 CloudFront에서 502 Bad Gateway 응답을 받게 되었습니다. 이를 해결하기 위해 공식 가이드 내용을 보았는데 잘 이해가 안되는 부분이 있어서 자세히 확인해 보았습니다.</p><h3>CloudFront 설정</h3><p><strong>Distribution setting</strong>에서 Alternate Domain Name으로 test.megazone.cf를 사용 합니다. 그리고 미리 준비해둔 ACM *.megazone.cf을 Custom SSL Certificate로 지정 해줬습니다.</p><p>즉, test.megazone.cf를 CloudFront의 서비스도메인으로 사용합니다.</p><p><strong>Origin setting</strong>은 Custom origin으로 Domain org.hedy.kim을 사용 하였습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*i5tGSwuMsVNTo44yPiFBvQ.png" /><figcaption>CloudFront Origin settings</figcaption></figure><p><strong>Origin server </strong>“org.hedy.kim”은 NGINX를 사용하였으며, 설정은 아래와 같이 하였습니다.</p><pre>server {<br>    listen 443 ssl;<br>    server_name _;</pre><pre>    # SSL Certificate<br>    ssl_certificate /certs/fullchain.pem;<br>    ssl_certificate_key /certs/privkey.pem;<br>    <br>    root /var/www/html/;<br>    index index.html;<br>}</pre><p><strong>Behavior 설정</strong>에서는 Cache Policy와 Origin Request Policy는 아래와 같이 Viewer request header 모두를 Origin으로 전달 하고, 모든 응답을 Cache하지 않도록 하였습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*Pv3a4CtRzzNVO0vuvVaykg.png" /><figcaption>CloudFront Default Cache Behavior Settings</figcaption></figure><h3>In My Dreams..</h3><p>여기까지 설정에 대한 예상 흐름은 아래와 그림과 같이</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*0-8IhGFC289BPp-Eq6dPzA.png" /><figcaption>In my dream..</figcaption></figure><p>Viewer와 CloudFront 사이에는 ACM 인증서 *.megazone.cf이 사용되고, CloudFront와 Origin server “org.hedy.kim” 사이에는 CA기관 발급 인증서 *.megazone.cf를 사용되어 아름답게 응답 프로세스가 진행 될 것 같았습니다.</p><h3>현실..</h3><blockquote>⚠️ 2021. 6. 25 업데이트 <br>글을 작성하던 시기와는 다르게, 현재 가이드와 같이 Origin Domain Name 또는 Host 중 하나라도 Origin의 SSL 인증서와 일치하면 문제가 생기지 않습니다.</blockquote><p>하지만, 실제 응답은…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*zW7eFtBKHXKfzHSEAvTCCg.png" /><figcaption>502 ERROR by CloudFront</figcaption></figure><p>AWS Document의 설명을 읽고 고민해 보았습니다. <br><a href="https://docs.amazonaws.cn/en_us/AmazonCloudFront/latest/DeveloperGuide/http-502-bad-gateway.html#ssl-negotitation-failure">https://docs.amazonaws.cn/en_us/AmazonCloudFront/latest/DeveloperGuide/http-502-bad-gateway.html#ssl-negotitation-failure</a></p><p>특히 이 문장</p><blockquote>To determine whether domain names in the certificate match the <strong>Origin Domain Name</strong> in the distribution or the Host header, you can use an online SSL checker or OpenSSL.</blockquote><p>Origin Domain Name 또는 Host 헤더가 인증서의 도메인과 일치되어야 한다는 것인데, CloudFront에서 Origin으로 요청하는 SNI와 Host 헤더 보다도 Origin Domain Name의 설정 값이 우선시 되는 것으로 보입니다. 그래서 실제 동작은 아래 그림과 같이</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*57iJnmANgeUtqK_-4FmpwA.png" /><figcaption>502 ERROR</figcaption></figure><p>SNI와 Host 헤더는 Origin 인증서에 일치(Match) 되지만, Origin Domain Name “org.hedy.kim”과는 일치되지 않아 유효하지 않는 것으로 처리 되어 502 응답 됩니다.</p><h3>결국에는..</h3><p>설정되어 있는 Origin Domain Name “org.hedy.kim”과 일치하는 인증서 *.hedy.kim으로 변경 후 최종 정상 응답을 받을 수 있는 것을 확인 할 수 있었습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*M1AHRULYpVz1gUfY-6cDsA.png" /><figcaption>200 OK</figcaption></figure><p>SNI와 Host 헤더는 Origin server에서 필터링 할 때 사용하는 것 외에는 SSL 인증서 유효성 검증에는 영향이 없는 것으로 보입니다.</p><blockquote>⚠️ 2021. 6. 25 업데이트 <br>글을 작성하던 시기와는 다르게, 현재 가이드와 같이 Origin Domain Name 또는 Host 중 하나라도 Origin의 SSL 인증서와 일치하면 문제가 생기지 않습니다.</blockquote><h3>마치며..</h3><p>사실 Origin Domain Name과 Origin 인증서 모두 CloudFront에 사용 하는 서비스 Domain(FQDN)과 동일한 Root domain(e.g example.com)으로 설정한다면 문제는 없겠지만, 하나의 Origin에 여러 도메인을 Virtual Host를 설정하여 사용하고 Origin 도메인을 하나로만 사용하게 된다면 이와 같은 혼란을 누군가는 겪게 되지 않을까 하여, 그런 어려움을 겪을 미래의 누군가에게 이 글이 도움이 되었으면 합니다.</p><p>.fin</p><blockquote><a href="https://www.facebook.com/CloudVillains">Cloud Villains Facebook P</a>age를 팔로우하시면 새로 발행되는 글의 알람을 더욱 손쉽게 받아보실 수 있습니다.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5c422ceffed" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudvillains/amazon-cloudfront-502-bad-gateway%EC%8B%9C-origin-ssl-%EC%9D%B8%EC%A6%9D%EC%84%9C-%EC%84%A4%EC%A0%95%EC%97%90-%EB%8C%80%ED%95%98%EC%97%AC-a5c422ceffed">Amazon CloudFront: 502 Bad Gateway시 Origin SSL 인증서 설정에 대하여</a> was originally published in <a href="https://medium.com/cloudvillains">Cloud Villains</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amazon CloudFront: Range GET Behavior]]></title>
            <link>https://medium.com/cloudvillains/amazon-cloudfront-range-get-behavior-e419e22f128f?source=rss-6dc5cfa66ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/e419e22f128f</guid>
            <category><![CDATA[behavior]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cdn]]></category>
            <category><![CDATA[cloudfront]]></category>
            <category><![CDATA[https]]></category>
            <dc:creator><![CDATA[Hedy Kim]]></dc:creator>
            <pubDate>Mon, 21 Jun 2021 01:50:10 GMT</pubDate>
            <atom:updated>2024-04-28T23:39:26.669Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZziQTpRB4zjXaZQF-H216Q.png" /></figure><h3>Abstract</h3><p>AWS 가이드 문서 내용 중 <a href="https://docs.aws.amazon.com/ko_kr/AmazonCloudFront/latest/DeveloperGuide/RangeGETs.html"><strong>CloudFront에서 객체에 대한 부분적인 요청을 처리하는 방법(Range GET)</strong></a>에 대하여, 실제 CloudFront 내에 Contents가 Cache 되고 응답 되는 동작을 자세히 분석하고자 합니다.</p><h3>What is Range GET?</h3><p>Range GET은 HTTP 스펙에 명시된 Request header “Range”에 대한 동작을 의미 합니다. 특히 사이즈가 큰 Content에 대해서 Client Application에서 1개의 Connection으로만 데이터를 받는 것보다, 여러개의 byte 단위로 분할하여 동시에 다운로드 받을시 Network Bandwidth 허용 범위 내에서 빠르게 다운로드 받을 수 있습니다.</p><ul><li>HTTP GET Request</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*15nT1PgJ28cg8u_IQArWOQ.png" /></figure><ul><li>HTTP Range GET Request</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*H1w8Kq6kmtdtjswEuTODSg.png" /></figure><h3>CloudFront Limitation for Range GET</h3><p>AWS 공식 문서에서는 ‘Origin에서 Range GET 요청을 지원 하는 경우 CloudFront에서는 Viewer가 요청하는 범위(Range bytes)를 포함 하는 범위(Range)로 오리진에 요청 합니다. ‘라고 되어 있습니다. <br>무슨말인지 쉽게 이해하기는 어려운 것 같습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*w3WcWsnQNTrf3ca1FeX3Rg.png" /></figure><p>아래 Case를 통해서 좀 더 자세히 살펴 보겠습니다.</p><h4>Case.1 Origin Request: Range bytes changed by CloudFront</h4><p>CloudFront에서 Origin request 시 Filesize의 실제크기 상관 없이, Viewer의 Range 범위에 대해 <strong>1MB(1048576Bytes) 단위로 범위를 변경하여 요청 </strong>합니다.</p><p>즉, Viewer request의 Range 기준으로 Origin request 시 1MB 단위로 Viewer request의 Range를 포함 할수 있는 Range로 변경합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*CXrP-USGsQPWxv5KqgCldQ.png" /></figure><ul><li>Viewer request Range = 0–1572863 (1.5MB)</li></ul><pre>GET /contents/test.mp4 HTTP/1.1<br>Host: d1i7c9c5nz38s4.cloudfront.net<br><strong>Range: bytes=0-1572863</strong></pre><pre>HTTP/1.1 206 Partial Content<br>Content-Type: video/mp4<br>Content-Length: 1572864<br>Connection: keep-alive<br>Server: nginx/1.18.0 (Ubuntu)<br>Date: Fri, 21 Aug 2020 04:36:14 GMT<br>Last-Modified: Fri, 21 Aug 2020 02:46:26 GMT<br>ETag: &quot;5f3f3582-123dcd14&quot;<br>Expires: Fri, 21 Aug 2020 04:41:14 GMT<br>Cache-Control: max-age=300<br>Content-Range: bytes 0-1572863/306040084<br>X-Cache: Miss from cloudfront<br>X-Amz-Cf-Pop: ICN54-C1<br>X-Amz-Cf-Id: 7ODuhrLtGAR92SGY4Es1eeQfJz7ZfGi1xQ2YnEaXNc5M6WY7UwTpKg==<br>Via: 1.1 4e7cb5238b8bf39c2881bea34913cbf4.cloudfront.net (CloudFront)</pre><ul><li>CloudFront Origin request Range = 0–2097151 (2MB)</li></ul><pre>GET /contents/test.mp4 HTTP/1.1<br>Host: d1i7c9c5nz38s4.cloudfront.net<br>X-Amz-Cf-Id: ovjoM2QaFQ8nppm_kIZoTuOCd9B5gtVxjwx1R9yGDq82XN5xN_CqQg==<br>Connection: Keep-Alive<br>Accept: */*<br>X-Forwarded-For: 221.148.35.240<br>Via: 1.1 552df32c91dfdb5fe974f3002e2d7f26.cloudfront.net (CloudFront)<br><strong>Range: bytes=0-2097151</strong></pre><pre>HTTP/1.1 206 Partial Content<br>Server: nginx/1.18.0 (Ubuntu)<br>Date: Fri, 21 Aug 2020 04:36:14 GMT<br>Content-Type: video/mp4<br>Content-Length: 2097152<br>Last-Modified: Fri, 21 Aug 2020 02:46:26 GMT<br>Connection: keep-alive<br>ETag: &quot;5f3f3582-123dcd14&quot;<br>Expires: Fri, 21 Aug 2020 04:41:14 GMT<br>Cache-Control: max-age=300<br>Content-Range: bytes 0-2097151/306040084</pre><h4>Case.2 Caching: Succession range cached contents on CloudFront</h4><p>요청하는 객체의 연속되는 2개의 범위(Range)를 각각 캐시 후, 다시 캐시된 연속범위(Range)에 포함되는 범위(Range)로 요청시에, CloudFront에서는 해당 범위(Range)를 Origin으로 다시 요청 합니다.</p><p>즉, 이미 캐시로 가지고 있는 범위 이지만 관계 없이 따로 캐시를 합니다.</p><p><strong>Step.1 <br></strong>연속되는 2개의 범위(Range)를 캐시 되도록 합니다. (같은 Edge로 요청 해야 합니다)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*UxHmIjmH4STmLC0Wy-ryBw.png" /></figure><ul><li>Range: bytes=0–2097151</li></ul><pre>HTTP/1.1 206 Partial Content<br>Content-Type: video/mp4<br><strong>Content-Length: 2097152<br></strong>Connection: keep-alive<br>Server: nginx/1.18.0 (Ubuntu)<br>Date: Fri, 21 Aug 2020 05:14:14 GMT<br>Last-Modified: Fri, 21 Aug 2020 02:46:26 GMT<br>ETag: &quot;5f3f3582-123dcd14&quot;<br>Expires: Fri, 21 Aug 2020 05:19:14 GMT<br>Cache-Control: max-age=300<br><strong>Content-Range: bytes 0-2097151/306040084<br>X-Cache: Hit from cloudfront<br></strong>X-Amz-Cf-Pop: ICN54-C1<br>X-Amz-Cf-Id: 2-KCc5zmmNL9h6aXrBi4ZXere8uoo3UoC6lfxjQ3_fy6lkXaTRTffw==<br>Via: 1.1 d78bccab0c9c23bf239c3eb6bcb06ecd.cloudfront.net (CloudFront)<br>Age: 6</pre><ul><li>Range: bytes=2097152–4194304</li></ul><pre>HTTP/1.1 206 Partial Content<br>Content-Type: video/mp4<br><strong>Content-Length: 2097153<br></strong>Connection: keep-alive<br>Server: nginx/1.18.0 (Ubuntu)<br>Date: Fri, 21 Aug 2020 05:14:38 GMT<br>Last-Modified: Fri, 21 Aug 2020 02:46:26 GMT<br>ETag: &quot;5f3f3582-123dcd14&quot;<br>Expires: Fri, 21 Aug 2020 05:19:38 GMT<br>Cache-Control: max-age=300<br><strong>Content-Range: bytes 2097152-4194304/306040084<br>X-Cache: Hit from cloudfront<br></strong>X-Amz-Cf-Pop: ICN54-C1<br>X-Amz-Cf-Id: o4oWCqgsqhPXwLgPbbTzRNXXqECIpbDUcEV-CNLccdylcS8EskmDqA==<br>Via: 1.1 69d52ca4892e7d7059399a0c393797ac.cloudfront.net (CloudFront)<br>Age: 2</pre><p><strong>Step.2<br></strong> 위에서 캐시한 범위(Range) 0–4194304가 포함되는 영역 1000–4000000으로 요청시 Miss 응답 됩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*gB-5x_cIEwgwwMdJB0YoiA.png" /></figure><ul><li>Range: bytes=1000–4000000</li></ul><pre>HTTP/1.1 206 Partial Content<br>Content-Type: video/mp4<br><strong>Content-Length: 3999001<br></strong>Connection: keep-alive<br>Server: nginx/1.18.0 (Ubuntu)<br>Date: Fri, 21 Aug 2020 05:15:13 GMT<br>Last-Modified: Fri, 21 Aug 2020 02:46:26 GMT<br>ETag: &quot;5f3f3582-123dcd14&quot;<br>Expires: Fri, 21 Aug 2020 05:20:13 GMT<br>Cache-Control: max-age=300<br><strong>Content-Range: bytes 1000-4000000/306040084<br>X-Cache: Miss from cloudfront<br></strong>X-Amz-Cf-Pop: ICN54-C1<br>X-Amz-Cf-Id: DegzL31cLvugzbdnUmkaPgONf_lqsMjhfzQPLZbpKPAXz7xFBSmLBA==<br>Via: 1.1 f872ea854cda487277bd77eed683ad7d.cloudfront.net (CloudFront)</pre><h3>Conclusion</h3><p>Range GET는 주로 미디어 서비스에서 Seeking 하거나 애플리케이션에서 큰 사이즈의 파일을 다운로드 받을 경우 필요로 하고 있습니다.</p><p>연속되는 범위의 캐시를 하나의 범위로 요청시에 다시 오리진으로 요청하여 별도로 캐시 하는 것으로 보아 Range 값을 Cache content의 Index로 활용 하는 것으로 보여 집니다. 또한 각각의 Range로 Cached 되어 있는 객체들에 대해서 개별적인 Invalidation(무효화)는 지원되지 않습니다.</p><p>이러한 점을 유의하여 사용 한다면, 대용량 파일에 대해서 Parallel 전략으로 좀더 빠르게 다운로드가 가능합니다.</p><h3>See also</h3><p><a href="https://tools.ietf.org/html/rfc7233#section-3.1">https://tools.ietf.org/html/rfc7233#section-3.1</a> — <em>HTTP/1.1 Range Requests<br></em><a href="https://tools.ietf.org/html/rfc7230#section-3.3.1">https://tools.ietf.org/html/rfc7230#section-3.3.1</a> — <em>HTTP/1.1 Message Syntax and Routing</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e419e22f128f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudvillains/amazon-cloudfront-range-get-behavior-e419e22f128f">Amazon CloudFront: Range GET Behavior</a> was originally published in <a href="https://medium.com/cloudvillains">Cloud Villains</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>