[TIL] HTTP : The Definitive Guide "p122 ~p124"

시윤·2024년 4월 1일
0

[TIL] Two Pages Per Day

목록 보기
52/110
post-thumbnail

Chapter 5. Web Servers

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


❤️ 원문 번역 ❤️

Step 4: Mapping and Accessing Resources

Directory Listings

A web server can receive requests for directory URLs, where the path resolves to a directory, not a file. Most web servers can be configured to take a few different actions when a client requests a directory URL:

  • Return an error.
  • Return a special, default, “index file” instead of the directory.
  • Scan the directory, and return an HTML page containing the contents.
  • 웹 서버는 디렉토리 URL에 대한 요청을 받을 수 있으며, 이때 경로는 파일이 아닌 디렉토리로 확인됩니다.

  • 대부분의 웹 서버는 클라이언트가 디렉토리 URL을 요청할 때 몇 가지 다른 액션을 취하도록 구성될 수 있습니다.
    - 오류를 반환하는 것
    - 디렉토리 대신 특수하고 유일한 "인덱스 파일"을 반환하는 것
    - 디렉토리를 스캔하여 콘텐츠를 포함한 HTML 페이지를 반환하는 것

Most web servers look for a file named index.html or index.htm inside a directory to represent that directory. If a user requests a URL for a directory and the directory contains a file named index.html (or index.htm), the server will return the contents of that file.

  • 웹 서버는 보통 디렉토리를 표현하기 위해 디렉토리 내부에서 index.html이나 index.htm으로 명명된 파일을 찾습니다.

  • 만약 사용자가 URL을 요청한 디렉토리가 index.html이라는 파일을 포함하고 있다면, 서버는 해당 파일의 콘텐츠를 반환할 것입니다.

In the Apache web server, you can configure the set of filenames that will be interpreted as default directory files using the DirectoryIndex configuration directive. The DirectoryIndex directive lists all filenames that serve as directory index files, in preferred order. The following configuration line causes Apache to search a directory for any of the listed files in response to a directory URL request:

DirectoryIndex index.html index.htm home.html home.htm index.cgi
  • Apache 웹 서버에서는 DirectoryIndex 구성 지침을 사용하여 디폴트 디렉토리 파일로 해석되는 파일명의 집합을 구성할 수 있습니다.

  • DirectoryIndex 기법은 디렉토리 인덱스 파일로 제공되는 모든 파일명을 지정된 순서로 나열합니다.

  • 다음의 구성 라인은 Apache 서버가 디렉토리 URL 요청에 대한 응답으로 임의의 나열된 파일에 대한 디렉토리를 검색할 수 있게 합니다.

If no default index file is present when a user requests a directory URI, and if directory indexes are not disabled, many web servers automatically return an HTML file listing the files in that directory, and the sizes and modification dates of each file, including URI links to each file. This file listing can be convenient, but it also allows nosy people to find files on a web server that they might not normally find.

  • 사용자의 디렉토리 URI 요청에 디폴트 인덱스 파일이 존재하지 않고 디렉토리 인덱스가 비활성화되지 않았다면, 많은 웹 서버는 해당 디렉토리의 파일을 나열하는 HTML 파일과 각 파일의 크기와 수정 날짜, URI 링크를 자동으로 반환합니다.

  • 이러한 파일의 목록은 편리하지만 악성 사용자들이 웹 서버에서 일반적으로 찾을 수 없는 파일을 찾을 수 있게 합니다.

You can disable the automatic generation of directory index files with the Apache directive:

Options -Indexes
  • Apache 지침에서는 Options -Indexes를 사용하여 디렉토리 인덱스 파일의 자동 생성을 비활성화할 수 있습니다.

Dynamic Content Resource Mapping

Web servers also can map URIs to dynamic resources—that is, to programs that generate content on demand (Figure 5-11). In fact, a whole class of web servers called application servers connect web servers to sophisticated backend applications. The web server needs to be able to tell when a resource is a dynamic resource, where the dynamic content generator program is located, and how to run the program. Most web servers provide basic mechanisms to identify and map dynamic resources.

  • 웹 서버는 URI를 동적 리소스, 즉 필요에 따라 콘텐츠를 생성하는 프로그램에 매핑할 수 있습니다. (Figure 5-11)

  • 애플리케이션 서버라고 불리는 모든 클래스의 웹 서버는 웹 서버를 정교한 백엔드 응용 프로그램과 연결합니다.

  • 웹 서버는 리소스가 동적 리소스인 경우 동적 콘텐츠 생성 프로그램은 어디에 위치해 있는지, 해당 프로그램을 어떻게 사용할 수 있는지 알 수 있어야 합니다.

  • 대부분의 웹 서버는 동적 리소스를 식별하고 매핑하기 위한 기본적인 매커니즘을 제공하고 있습니다.

Apache lets you map URI pathname components into executable program directories. When a server receives a request for a URI with an executable path compo- nent, it attempts to execute a program in a corresponding server directory. For example, the following Apache configuration directive specifies that all URIs whose paths begin with /cgi-bin/ should execute corresponding programs found in the directory /usr/local/etc/httpd/cgi-programs/:

ScriptAlias /cgi-bin/ /usr/local/etc/httpd/cgi-programs/
  • Apache는 URI의 pathname 구성 요소를 실행 가능한 프로그램 디렉토리와 매핑합니다.

  • 서버는 실행 가능한 path 구성 요소와 URI에 대한 요청을 받으면 일치하는 서버 디렉토리에 위치한 프로그램을 실행하려고 시도합니다.

  • 예를 들어, 다음의 Apache 구성 지침은 /cgi-bin/로 시작하는 모든 URI가 /usr/local/etc/httpd/cgi-programs/와 일치하는 디렉토리에서 발견되는 프로그램을 실행해야 함을 명시합니다.

Apache also lets you mark executable files with a special file extension. This way, executable scripts can be placed in any directory. The following Apache configura- tion directive specifies that all web resources ending in .cgi should be executed:

AddHandler cgi-script .cgi
  • 또한 Apache를 사용하면 실행 가능한 파일을 특수한 파일 확장자로 표시할 수 있습니다.

  • 이 방식으로 실행 가능한 스크립트가 어느 디렉토리에든 위치할 수 있습니다.

  • 다음의 Apache 구성 지침은 .cgi로 끝나는 모든 웹 리소스가 실행되어야 함을 명시합니다.

CGI is an early, simple, and popular interface for executing server-side applications. Modern application servers have more powerful and efficient server-side dynamic content support, including Microsoft’s Active Server Pages and Java servlets.

  • CGI는 서버 사이드 응용 프로그램을 실행하는 간단하고 인기 있는 초기의 인터페이스입니다.

  • 오늘날의 응용 프로그램 서버는 Microsoft의 Active Server Pages와 Java servlet처럼 더 효율적인 서버 사이드의 동적 콘텐츠 지원 기능을 가지고 있습니다.


Server-Side Includes

Many web servers also provide support for server-side includes. If a resource is flagged as containing server-side includes, the server processes the resource contents before sending them to the client.

  • 많은 웹 서버가 server-side indluces에 대한 지원을 제공하고 있습니다.

  • 리소스가 server-side includes를 포함하는 것으로 플래그가 지정되면 서버는 클라이언트에게 전송하기 전 리소스 콘텐츠를 처리합니다.

The contents are scanned for certain special patterns (often contained inside special HTML comments), which can be variable names or embedded scripts. The special patterns are replaced with the values of variables or the output of executable scripts. This is an easy way to create dynamic content.

  • 콘텐츠는 (일반적으로 특수한 HTML 주석 내부에 포함되어 있는) 특수한 패턴으로 스캔됩니다. 이 패턴은 변수의 이름이거나 내장된 스크립트일 수 있습니다.

  • 해당 특수 패턴은 변수의 값이나 실행 가능한 스크립트의 결과로 대체됩니다.

  • 이것은 동적 콘텐츠를 생성하는 손쉬운 방법입니다.


Access Controls

Web servers also can assign access controls to particular resources. When a request arrives for an access-controlled resource, the web server can control access based on the IP address of the client, or it can issue a password challenge to get access to the resource.

  • 웹 서버는 특정 리소스에 대해 접근을 제어할 수 있습니다.

  • access-controlled 리소스에 대한 요청이 도착하면 웹 서버는 클라이언트의 IP 주소를 바탕으로 접근을 제어하거나 리소스에 접근하기 위해 패스워드를 입력하게 할 수도 있습니다.

Refer to Chapter 12 for more information about HTTP authentication.

  • HTTP 인증에 대한 자세한 정보는 Chapter 12를 참고하여 주시기 바랍니다.

🧡 요약 정리 🧡

Step 1: Accepting Client Connections
Step 2: Receiving Request Messages
Step 3: Processing Requests

Step 4: Mapping and Accessing Resources

Directory Listings

: 웹 서버는 디렉토리에 대한 URL을 요청 받을 수 있다

    1. 디렉토리 내부에서 index.html 혹은 index.htm을 찾아 반환
    1. DirectoryIndex 지침에 따라 여러 개의 디렉토리 index 파일 반환
    1. index 파일이 존재하지 않고 디렉토리 index가 비활성화되지 않았다면 해당 디렉토리의 파일을 나열한 HTML 파일과 정보 반환
    1. 오류 반환

Dynamic Content Resource Mapping

: 웹 서버는 URI를 동적 리소스와 매핑할 수 있다

  • 애플리케이션 서버 : 웹 서버와 백엔드 응용 프로그램 연결
  • 웹 서버 : 동적 콘텐츠 생성 프로그램의 위치와 사용법을 알고 있다
  • Apache는 프로그램 디렉토리에서 pathname 구성 요소와 일치하는 프로그램을 매핑하여 실행할 수 있다
  • Apache는 특수한 파일 확장자로 끝나는 실행 가능한 웹 리소스를 매핑하여 실행할 수 있다
  • SSI(Server-Side Includes) : 동적 콘텐츠 생성법, HTML과 같은 리소스 콘텐츠에 특수 패턴을 삽입하여 웹 서버가 해당 코드의 실행 결과를 리소스 콘텐츠에 포함하게 하는 것

💛 감상 💛

  • 주말 동안 아주 푹 쉬고 오셨습니다. 월요일이니까 새로운 마음으로 다시 업로드를 해보겠습니다...
profile
맑은 눈의 다람쥐

0개의 댓글

관련 채용 정보