HTTP 완벽가이드 21장

13
HTTP: The Definitive Guide (ch.21 로깅과 사용 추적) 아키텍트를 꿈꾸는 사람들 Cecil

Transcript of HTTP 완벽가이드 21장

Page 1: HTTP 완벽가이드 21장

HTTP:�The�Definitive�Guide�(ch.21�로깅과�사용�추적)

아키텍트를�꿈꾸는�사람들�Cecil

Page 2: HTTP 완벽가이드 21장

웹�서버�로깅의�목적

오류�발생시�문제의�원인을�찾기�위해�

사이트의�접근�통계를�위해

Page 3: HTTP 완벽가이드 21장

일반적인�HTTP�로깅�필드

HTTP�메서드,�HTTP�버전,�요청�받은�리소스의�URL,�

응답�상태�코드,�요청과�응답�메시지�크기,��

트랜잭션이�일어나�시간,�Referer와�User-Agent�헤더

Page 4: HTTP 완벽가이드 21장

표준화된�로그�포멧을�사용하자�

웹�로깅에�표준화된�로그�포멧을�사용할�경우,�이와�호환이�되는�

이미�만들어진�툴들을�이용할�수�있다.(통계,�에러�분석�등등)

Page 5: HTTP 완벽가이드 21장

일반�로그�포멧(Common�Log)필드 설명

remotehost 요청한�컴퓨터의�호스트�명�혹은�IP주소

username ident�검색을�수행했다면,�인증된�요청자의�사용자�이름

auth-username 인증을�수행했다면,�인증된�요청자의�이름

timestamp 요청�날짜와�시간

request-line HTTP�요청�라인

response-code 응답�상태�코드

response-size 응답�엔터티의�Content-Length

209.1.32.44�-�-�[03/Oct/1999:14:16:00�-0400]�"GET�/�HTTP/1.0"�200�1024�http-guide.com�-�dg�[03/Oct/1999:14:16:32�-0400]�"GET�/�HTTP/1.0"�200�477�http-guide.com�-�dg�[03/Oct/1999:14:16:32�-0400]�"GET�/foo�HTTP/1.0"�404�0

Page 6: HTTP 완벽가이드 21장

혼합�로그�포멧(Combined�Log)

필드 설명

Referer 어느�사이트에서�링크를�따라�왔는지

User-Agent HTTP�클라이언트�애플리케이션�정보

209.1.32.44�-�-�[03/Oct/1999:14:16:00�-0400]�"GET�/�HTTP/1.0"�200�1024�"http://www.joes-hardware.com/"��"5.0:�Mozilla/4.0�(compatible;�MSIE�5.0;�Windows�98)"

일반�로그�포멧에�2개의�추가�필드�사용

Page 7: HTTP 완벽가이드 21장

넷스케이프�확장�로그�포멧

필드 설명

proxy-response-code 프락시를�거칠�경우,�프락시로의�HTTP�응답�코드

proxy-response-size 프락시를�거칠�경우,�서버가�프락시에�전달하는�응답의�엔터티�크기

client-request-size 클라이언트가�프락시로�보내는�요청의�엔터티�크기

proxy-request-size 프락시를�거칠�경우,�프락시가�서버로�보내는�요청의�엔터티�크기

client-request-hdr-size 클라이언트�요청�헤더의�크기

proxy-request-hdr-size 프락시를�거칠�경우,�프락시가�서버로�전송하는�요청�헤더의�크기

server-response-hdr-size 서버�응답�헤더의�크기

proxy-timestamp 프락시를�거칠�경우,�요청과�응답이�프락시를�통해�오가는�총�시간

209.1.32.44�-�-�[03/Oct/1999:14:16:00-0400]�"GET�/�HTTP/1.0"�200�1024�200�1024�0�0�215�260�279�254�3�

프락시나�웹�캐시와�같은�여러�환경을�지원하기�위해�일반�로그�포멧을�확장

Page 8: HTTP 완벽가이드 21장

넷스케이프�확장�2�로그�포멧

필드 설명

route 프락시가�클라이언트로의�응답을�만드는데�사용한�경로

client-finish-status-code 클라이언트의�요청의�종료�상태�코드(클라이언트->프락시)�FIN,�INTR�…

proxy-finish-status-code 프락시의�종료�상태�코드(서버�->�프락시)�FIN,�INTR�…

cache-result-code 캐시�결과�코드,�캐시가�요청에�어떻게�응답했는지를�기술

209.1.32.44�-�-�[03/Oct/1999:14:16:00-0400]�"GET�/�HTTP/1.0"�200�1024�200�1024�0�0�215�260�279�254�3�DIRECT�FIN�FIN�WRITTEN�

확장�로그�포멧에서�프락시와�웹�캐시와�관련한�더�많은�정보를�제공

Page 9: HTTP 완벽가이드 21장

적중�계량하기

서버는�접근�통계를�위해�상세�로그를�저장(ex:�광고�서비스)�

만약,�중간에�캐시가�있다면??�

해당�컨텐츠가�얼마나�조회가�되었는지를�서버가�알수�없음�

적중�계량(Hit�Metering):�캐시가�정기적으로�캐시�접근�통계를�서버에�보고

Page 10: HTTP 완벽가이드 21장

This is the Title of the Book, eMatter EditionCopyright © 2008 O’Reilly & Associates, Inc. All rights reserved.

494 | Chapter 21: Logging and Usage Tracking

Figure 21-1 shows an example of Hit Metering in action. The first part of the transac-tion is just a normal HTTP transaction between a client and proxy cache, but in theproxy request, note the insertion of the Meter header and the response from theserver. Here, the proxy is informing the server that it is capable of doing Hit Meter-ing, and the server in turn is asking the proxy to report its hit counts.

The request completes as it normally would, from the client’s perspective, and theproxy begins tracking hits to that resource on behalf of the server. Later, the proxytries to revalidate the resource with the server. The proxy embeds the metered infor-mation it has been tracking in the conditional request to the server.

Figure 21-1. Hit Metering example

Request message

Client

GET http://joes-hardware.com/ HTTP/1.1Host: www.joes-hardware.comAccept: *

www.joes-hardware.com

GET / HTTP/1.1Host: www.joes-hardware.comMeter: will-report-and-limitConnection: Meter

Response message

HTTP/1.1 200 OKDate: Fri, 06 Dec 1996 18:44:29 GMTContent-length: 3152Content-type: text/htmlConnection: MeterETag: "v1.27"Meter: do-report

[...]

Proxy

Client

Later, the cache revalidates theresponse and at the same timereports the hit count

www.joes-hardware.com

GET / HTTP/1.1Host: www.joes-hardware.comMeter: 12/4If-None-Match: "v1.27"Connection: Meter

HTTP/1.1 304 Not Modified

[...]

Response sent to client, cached, andused for subsequent requests

Proxy

Proxy

HTTP/1.1 200 OKDate: Fri, 06 Dec 1996 18:44:29 GMTContent-length: 3152Content-type: text/html

[...]

www.it-ebooks.info

Meter�헤더�사용�

프락시는�리소스에�대한�재

검사�요청시�해당�리소스가�

조회된�횟수를�서버에�전송

Page 11: HTTP 완벽가이드 21장

개인�정보�보호�

로깅은�관리자와�개발자에게�유용한�도구지만�로깅을�당하는�사용자들

의�인지나�허가가�없으면�로깅이�사생할�침해가�된다는�것을�유념

Page 12: HTTP 완벽가이드 21장

Q&A

Page 13: HTTP 완벽가이드 21장

References• David�Gourley,�Brian�Totty,�Marjorie�Sayer,�Sailu�Reddy,�

Anshu�Aggarwal.�HTTP�완벽�가이드(이응준,�정상일�옮김).�서울시�마포구:�인사이트,�2014