[TIL] HTTP : The Definitive Guide "p113 ~ p116"

시윤·2024년 3월 27일
0

[TIL] Two Pages Per Day

목록 보기
49/109
post-thumbnail

Chapter 5. Web Servers

(해석 또는 이해가 잘못된 부분이 있다면 댓글로 편하게 알려주세요.)


❤️ 원문 번역 ❤️

What Real Web Servers Do

The Perl server we showed in Example 5-1 is a trivial example web server. State-of-the-art commercial web servers are much more complicated, but they do perform several common tasks, as shown in Figure 5-3:

  • Example 501에 나타난 Perl 서버는 웹 서버의 작은 예시일 뿐입니다.

  • 최첨단 상용 웹 서버는 훨씬 더 정교하지만 Figure 5-3과 같은 몇 가지 일반적인 동작을 수행합니다.

  1. Set up connection—accept a client connection, or close if the client is unwanted.
    1. 연결 설정 - 클라이언트 연결을 승인하거나, 클라이언트가 원하지 않는다면 연결 종료
  1. Receive request—read an HTTP request message from the network.
    1. 요청 수신 - 네트워크로 전달된 HTTP 요청 메시지 읽기
  1. Process request—interpret the request message and take action.
    1. 요청 처리 - 요청 메시지 해석 및 액션 수행
  1. Access resource—access the resource specified in the message.
    1. 리소스 접근 - 메시지로 특정된 리소스에 접근
  1. Construct response—create the HTTP response message with the right headers.
    1. 응답 생성 - 올바른 헤더를 가진 HTTP 응답 메시지 생성
  1. Send response—send the response back to the client.
    1. 응답 전송 - 클라이언트에게 응답 반환
  1. Log transaction—place notes about the completed transaction in a log file.
    1. 로그 트랜잭션 - 로그 파일에 완료된 트랜잭션에 대해 기록

Step 1: Accepting Client Connections

If a client already has a persistent connection open to the server, it can use that connec- tion to send its request. Otherwise, the client needs to open a new connection to the server (refer back to Chapter 4 to review HTTP connection-management technology).

  • 만약 클라이언트가 이미 서버와의 Persistent 연결을 보유하고 있다면 요청을 전송하기 위해 해당 연결을 사용할 수 있습니다.

  • 그렇지 않다면 클라이언트는 서버에게 새로운 연결을 열어야 합니다. (HTTP의 연결 관리 기술을 리뷰하기 위해서는 Chapter 4를 참고합니다)

Handling New Connections

When a client requests a TCP connection to the web server, the web server establishes the connection and determines which client is on the other side of the connection, extracting the IP address from the TCP connection. Once a new connection is established and accepted, the server adds the new connection to its list of existing web server connections and prepares to watch for data on the connection.

  • 클라이언트가 웹 서버에 TCP 연결을 요청할 때, 웹 서버는 연결을 설정한 후 TCP 연결에서 IP 주소를 추출하여 연결의 맞은편에 있는 클라이언트를 결정합니다.

  • 새로운 연결이 설정 및 승인되면 서버는 존재하는 웹 서버 연결 리스트에 새로운 연결을 추가합니다. 그리고 이 연결에 데이터가 들어오는지 확인할 준비를 시작합니다.

The web server is free to reject and immediately close any connection. Some web servers close connections because the client IP address or hostname is unauthorized or is a known malicious client. Other identification techniques can also be used.

  • 웹 서버는 자유롭게 모든 연결을 거부하고 즉시 종료할 수 있습니다.

  • 일부 웹 서버는 클라이언트의 IP 주소나 호스트명이 인증되지 않았거나 알려진 악성 클라이언트일 때 연결을 종료합니다.

  • 이 외의 다른 식별 기술도 사용될 수 있습니다.

Client Hostname Identification

Most web servers can be configured to convert client IP addresses into client hostnames, using “reverse DNS.” Web servers can use the client hostname for detailed access control and logging. Be warned that hostname lookups can take a very long time, slowing down web transactions. Many high-capacity web servers either disable hostname resolution or enable it only for particular content.

  • 대부분의 웹 서버는 "reverse DNS"를 사용하여 클라이언트의 IP 주소를 호스트명으로 변경하도록 구성될 수 있습니다.

  • 웹 서버는 자세한 접근 제어와 로깅을 위해 클라이언트의 호스트명을 사용할 수 있습니다.

  • 단 호스트명을 찾는 것은 매우 오랜 시간이 걸리며 웹 트랜잭션의 속도를 늦춘다는 것에 유의합니다.

  • 많은 고성능 웹 서버들은 호스트명 확인을 비활성화하거나 특정 콘텐츠에 대해서만 가능하게 합니다.

You can enable hostname lookups in Apache with the Hostname Lookups configuration directive. For example, the Apache configuration directives in Example 5-2 turn on hostname resolution for only HTML and CGI resources.

Example 5-2. Configuring Apache to look up hostnames for HTML and CGI resources

HostnameLookups off
<Files ~ "\.(html|htm|cgi)$">
    HostnameLookups on
</Files>
  • Apache에서는 호스트명 검색 구성 지침을 활용하여 호스트명을 검색할 수 있게 합니다.

  • 예를 들어, Example 5-2의 Apache 구성 지침은 오직 HTML과 CGI 리소스에 대해서만 호스트명을 확인하여 반환합니다.

Determining the Client User Through ident

Some web servers also support the IETF ident protocol. The ident protocol lets servers find out what username initiated an HTTP connection. This information is particularly useful for web server logging—the second field of the popular Common Log Format contains the ident username of each HTTP request.

  • 일부 웹 서버는 IETF ident 프로토콜을 지원하기도 합니다.

  • ident 프로토콜은 서버가 HTTP 연결을 시작한 유저의 이름을 확인할 수 있게 합니다.

  • 이 정보는 부분적으로 웹 서버 로깅에 유용하게 사용됩니다. 자주 사용되는 Common Log Format의 두 번째 필드에는 각 HTTP 요청의 ident 유저 이름이 포함됩니다.

If a client supports the ident protocol, the client listens on TCP port 113 for ident requests. Figure 5-4 shows how the ident protocol works. In Figure 5-4a, the client opens an HTTP connection. The server then opens its own connection back to the client’s identd server port (113), sends a simple request asking for the username corresponding to the new connection (specified by client and server port numbers), and retrieves from the client the response containing the username.

  • 만약 클라이언트가 ident 프로토콜을 지원한다면, 클라이언트는 TCP 113 포트에서 ident 요청을 수신합니다.

  • Figure 5-4는 ident 프로토콜의 작동 방식을 보여줍니다.

  • Figure 5-4a에서 클라이언트는 HTTP 연결을 엽니다.

  • 서버는 고유한 연결을 열어 클라이언트의 identd 서버 포트(113)에 연결합니다. 그 다음 새로운 연결에 상응하는 유저명(클라이언트와 서버 포트 번호에 의해 특정)을 묻는 간단한 요청을 전송합니다. 마지막으로 클라이언트로부터 유저명을 포함하는 응답을 돌려받습니다.

ident can work inside organizations, but it does not work well across the public Internet for many reasons, including:

  • Many client PCs don’t run the identd Identification Protocol daemon software.
  • The ident protocol significantly delays HTTP transactions.
  • Many firewalls won’t permit incoming ident traffic.
  • The ident protocol is insecure and easy to fabricate.
  • The ident protocol doesn’t support virtual IP addresses well.
  • There are privacy concerns about exposing client usernames.
  • ident는 조직 내에서는 잘 작동하지만 공중 인터넷에서는 여러 가지 원인으로 잘 작동하지 못합니다.

  • 많은 클라이언트 PC가 identd 식별 프로토콜 데몬 소프트웨어를 실행하지 않습니다.

  • ident 프로토콜은 HTTP 트랜잭션을 심각하게 지연시킵니다.

  • 많은 방화벽이 ident 트래픽이 들어오는 것을 허용하지 않습니다.

  • ident 프로토콜은 보안상 안전하지 않고 조작하기 쉽습니다.

  • ident 프로토콜은 가상 IP 주소를 잘 지원하지 않습니다.

  • 클라이언트의 유저명이 노출되는 것에 대한 개인정보 보호 문제가 있습니다.

You can tell Apache web servers to use ident lookups with Apache’s IdentityCheck on directive. If no ident information is available, Apache will fill ident log fields with hyphens (-). Common Log Format log files typically contain hyphens in the second field because no ident information is available.

  • Apache 웹 서버에게 Apache 지침의 IdentityCheck를 사용하여 ident 검색을 사용할 것을 지시할 수 있습니다.

  • 만약 ident 정보를 이용할 수 없다면 Apache는 ident 로그 필드를 하이픈 기호로 채울 것입니다.

  • Common Log Format 로그 파일은 두 번째 필드에 하이픈을 포함하는 것이 전형적입니다. ident 정보를 이용할 수 없기 때문입니다.


🧡 요약 정리 🧡

What Web Servers Do

Step 1: Accepting Client Connections

    1. 클라이언트가 웹 서버에 TCP 연결 요청
    1. 웹 서버가 연결을 승인하고자 한다면 연결을 설정한 후 IP주소 추출 -> 클라이언트 확인

      Reverse DNS : IP 주소 -> 호스트명 확인
      ident 프로토콜 : HTTP 연결을 시작한 유저명 확인 (많은 클라이언트가 사용 X, 방화벽에 막히거나 개인정보 유출 우려)
      공통적인 단점 : 트랜잭션 시간 지연

    1. 웹 서버의 연결 목록에 새로운 연결 추가
    1. 웹 서버가 자유롭게 연결 종료 가능

💛 감상 💛

  • 서버를 공부하고 있지만 정작 서버가 무엇인가? 웹 서버가 무엇인가?라는 질문에 명확하게 답변을 하기는 쉽지 않은 것 같습니다. 주구장창 코드를 짠다고 해서 '서버'라는 단어가 마음에 와닿는 것은 아니니까요. 이 단어를 온전히 이해하고 느끼기 위해서는 앞으로도 많은 공부가 필요하다고 생각합니다. 아마 답을 찾기 위해서는 이 책을 읽고 정리하는 것을 넘어서 더 많은 자료들을 찾아봐야 할 겁니다.

  • 어제 포스팅을 안 올려서 오늘 2개를 올립니다. 여러모로 시간에 여유가 있는 수요일이라 과감하게 많이 읽었습니다. 사실 운영체제 강의 듣다가 지쳐서 하나 더 올리는 겁니다...ㅎㅎ 그래도 오늘 중에 목표치만큼 운영체제도 공부하다 잘 겁니다.

profile
맑은 눈의 다람쥐

0개의 댓글

관련 채용 정보