[Linux]Apache서버(httpd)의 환영 페이지 응답 절차
Rocky Linux 서버에 httpd 패키지(Apache 서버)를 설치/시작하고 브라우저에서 http://ip_address 페이지에 접속하면 아래와 같은 환영 메세지 페이지가 출력됩니다. 환영 메세지 페이지가 어떻게 출력되는지 절차를 확인해 보겠습니다.
- httpd 서비스의 환경설정 파일(/etc/httpd/conf/httpd.conf)에서 DocumentRoot 지시자 확인
– DocumentRoot 지시자에 등록된 디렉터리(“/var/www/html”)에서 인텍스 파일을 찾습니다.
– DirectoryIndex 지시자에 인텍스 파일을 정의합니다.[root@rocky9u2 conf]# vi httpd.confDocumentRoot "/var/www/html" <Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> <IfModule dir_module> DirectoryIndex index.html </IfModule> - “/var/www/html” 디렉터리 확인
– 인텍스 파일(index.html)이 없습니다. 이상한 일입니다. 인테스 파일이 없는데도 환영 메세지 페이지가 출력되고 있습니다. 다른 설정 사항이 있겠죠?[root@rocky9u2 conf]# ls -al /var/www/htmltotal 0 drwxr-xr-x 2 root root 6 Nov 15 09:50 . drwxr-xr-x 4 root root 33 Nov 15 09:26 .. - httpd.conf 파일의 맨 마지막 줄에 “IncludeOptional conf.d/*.conf”가 보입니다.
– IncludeOptional 지시자는 다른 파일로부터 추가 옵션들을 읽어드린다는 설정입니다.[root@rocky9u2 conf]# vi httpd.confIncludeOptional conf.d/*.conf - /etc/httpd/conf.d 디렉터리로 이동하여 파일 목록 출력
– autoindex.conf: 디렉토리 내의 파일 목록을 자동으로 생성하는 기능을 구성
– userdir.conf: 사용자 개인 디렉터리에 대한 접근을 구성
– welcome.conf: Apache 웹 서버의 환영 페이지 설정[root@rocky9u2 conf]# cd ../conf.d/; ls -altotal 28 drwxr-xr-x 2 root root 107 Nov 15 10:15 . drwxr-xr-x 5 root root 105 Nov 15 09:26 .. -rw-r--r-- 1 root root 2916 May 17 05:21 autoindex.conf -rw-r--r-- 1 root root 400 May 17 05:21 README -rw-r--r-- 1 root root 1252 May 17 05:18 userdir.conf -rw-r--r-- 1 root root 653 May 17 05:18 welcome.conf - welcome.conf 파일을 열어보겠습니다
– “LocationMatch” 지시자: 특정 경로 패턴에 대한 설정을 지정, “^/+$”는 최소 1개 이상의 슬래시(/)로만 구성된 경로를 의미합니다
– “Options -Indexes” 설정: 접근 디렉터리에 인텍스 파일(index.html)이 없는 경우에는 디렉터리의 파일 목록을 자동으로 생성하지 않고, “403 Forbidden” 오류가 발생시킵니다.
– “ErrorDocument 403” 설정 – “403 Forbidden” 오류가 발생하면 /.noindex.html 페이지를 출력합니다.
– “Alias /.noindex.html” 설정: /.noindex.html 페이지가 요청되면 /usr/share/httpd/noindex/index.html 페이지를 출력합니다.[root@rocky9u2 conf.d]# vi welcome.conf<LocationMatch "^/+$"> Options -Indexes ErrorDocument 403 /.noindex.html </LocationMatch> <Directory /usr/share/httpd/noindex> AllowOverride None Require all granted </Directory> Alias /.noindex.html /usr/share/httpd/noindex/index.html Alias /poweredby.png /usr/share/httpd/icons/apache_pb3.png Alias /system_noindex_logo.png /usr/share/httpd/icons/system_noindex_logo.png - /usr/share/httpd/noindex/index.html 파일이 환영 메시지 페이지인지 확인합니다.
[root@rocky9u2 conf.d]# grep "HTTP Server Test Page" /usr/share/httpd/noindex/index.html<title>HTTP Server Test Page powered by: Rocky Linux</title>