- 가장 널리 사용되는 웹 서버 소프트웨어 중 하나
- 정확한 명칭은 "Apache HTTP Server"
- 클라이언트로부터 HTTP 요청을 받아들이고, 정적인 웹 페이지나 동적인 콘텐츠(PHP, Python, Perl 등)를 서비스하는 역할
- SSL/TLS 프로토콜을 이용하여 보안 소켓 레이어(SSL)를 제공
- HTTP 프로토콜을 이용한 요청(Request)/응답(Response) 기반 서비스
- 요청 수신 -> 요청 분석 -> 리소스 검색 -> 모듈 처리 -> 응답 생성 -> 응답 전송 -> 연결 종료
yum install -y gcc openssl openssl-devel pcre pcre-devel apr apr-devel apr-util apr-util-devel]# cd /tmp/ ]# wget http://apache.tt.co.kr/httpd/httpd-2.4.41.tar.gz ]# tar -zxvf httpd-2.4.41.tar.gz ]# cd httpd-2.4.41 ]# ./configure --prefix=/edu/apache/httpd-2.4.41 --enable-mpms-shared=all --with-mpm=worker --enable-ssl --enable-rewrite ]# make ]# make install
https://tomcat.apache.org/download-connectors.cgi 다운로드
]# cd /tmp ]# wget https://archive.apache.org/dist/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.46-src.tar.gz ]# tar -zxvf tomcat-connectors-1.2.46-src.tar.gz ]# cd tomcat-connectors-1.2.46-src/native ]# ./configure --with-apxs=/edu/apache/httpd-2.4.41/bin/apxs ]# make ]# cp apache-2.0/mod_jk.so /edu/apache/httpd-2.4.41/modules ]# mkdir -p /log/apache/jk-log
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/extra/workers.properties
JkLogFile "|/edu/apache/httpd-2.4.41/bin/rotatelogs /log/apache/jk-log/jk.log.%Y%m%d 86400 +540“
JkLogLevel error
JkLogStampFormat "[%Y %a %b %d %H:%M:%S]"
JKRequestLogFormat " [%w:%R][%V] [%U][%s] [%T]“
JkMountFile conf/extra/uriworkermap.properties
JkShmFile /log/apache/jk-log/mod-jk.shm
### Apache Module
>
- Apache HTTP Server의 기능을 확장하고 추가하는 소프트웨어 컴포넌트
- 서버의 동작을 제어하고 사용자 정의된 기능을 추가
Core
Apache에서 기본적으로 로딩되는 모듈
MPM
Multi-Processing Module
FOR Linux(Default:Prefork)
prefork: non-threaded, proforking
worker: multi-threaded multi-process기타
mod_actions
이 모듈은 미디어종류나 요청메서드에 따라 CGI 스크립트를 실행한다.
mod_alias
파일시스템의 다른 부분들을 문서 계층구조에 포함하고, URL 리다이렉션을 제공한다
mod_asis
HTTP 헤더를 포함한 파일을 보낸다
mod_auth_basic
Basic authentication
mod_auth_digest
MD5 Digest Authentication을 사용한 사용자인증.
mod_authn_alias
Provides the ability to create extended authentication providers based on actual providers
mod_authn_anon
인증영역에 "익명(anonymous)" 사용자의 접근을 허용한다
mod_authn_dbd
User authentication using an SQL database
mod_authn_dbm
DBM 파일을 사용한 사용자 인증
mod_authn_default
최후 인증모듈
mod_authn_file
문자파일을 이용한 사용자 인증
mod_authnz_ldap
Allows an LDAP directory to be used to store the database for HTTP Basic authentication.
mod_authz_dbm
DBM 파일을 사용한 그룹 인증
mod_authz_default
최후 권한부여모듈
mod_authz_groupfile
일반 문자파일을 이용한 그룹 권한부여
mod_authz_host
호스트 (이름이나 IP 주소)를 사용한 그룹 권한부여
mod_authz_owner
파일 소유자를 이용한 권한부여
mod_authz_user
사용자 권한부여
mod_autoindex
자동으로 유닉스의 ls 명령어나 Win32의 dir 쉘명령어와 유사한 디렉토리 목록을 만든다
mod_cache
URI를 키로 사용하여 내용을 캐쉬한다.
mod_cern_meta
CERN 웹서버 메타파일 지원
mod_cgi
CGI 스크립트 실행
mod_cgid
외부 CGI 데몬을 사용하여 CGI 스크립트를 실행
mod_charset_lite
문자집합 변환을 지정
mod_dav
Distributed Authoring and Versioning (WebDAV) 기능
mod_dav_fs
mod_dav을 위한 파일시스템 제공자
mod_dav_lock
generic locking module for mod_dav
mod_dbd
Manages SQL database connections
mod_deflate
내용을 클라이언트로 보내기 전에 압축한다
mod_dir
"마지막 슬래쉬" 리다이렉션을 제공하고 디렉토리 index 파일을 서비스한다
mod_disk_cache
Content cache storage manager keyed to URIs
mod_dumpio
Dumps all I/O to error log as desired.
mod_echo
프로토콜 모듈을 설명하기위한 간단한 echo 서버
mod_env
CGI 스크립트나 SSI 페이지에 전달할 환경변수를 수정한다
mod_example
아파치 모듈 API를 설명한다
mod_expires
사용자가 지정한 기준에 따라 Expires와 Cache-Control HTTP 헤더를 생성한다
mod_ext_filter
응답 내용을 외부 프로그램으로 처리한 후 클라이언트로 보낸다
mod_file_cache
메모리에 정적 파일들을 캐쉬
mod_filter
Context-sensitive smart filter configuration module
mod_headers
HTTP 요청 헤더와 응답 헤더 수정
mod_ident
RFC 1413 ident 검색
mod_imagemap
서버측 이미지맵(imagemap) 처리
mod_include
Server-parsed html documents (Server Side Includes)
mod_info
서버 설정에 대한 종합적인 정보를 보여준다
mod_isapi
Windows용 아파치에서 ISAPI Extension 사용
mod_ldap
LDAP connection pooling and result caching services for use by other LDAP modules
mod_log_config
서버로의 요청을 로그에 기록한다
mod_log_forensic
Forensic Logging of the requests made to the server
mod_logio
요청당 입출력 바이트수를 기록
mod_mem_cache
URI를 키로 사용하여 내용을 캐쉬한다.
mod_mime
Associates the requested filename's extensions with the file's behavior (handlers and filters) and content (mime-type, language, character set and encoding)
mod_mime_magic
Determines the MIME type of a file by looking at a few bytes of its contents
mod_negotiation
Provides for content negotiation
mod_nw_ssl
Enable SSL encryption for NetWare
mod_proxy
HTTP/1.1 proxy/gateway server
mod_proxy_ajp
AJP support module for mod_proxy
mod_proxy_balancer
mod_proxy extension for load balancing
mod_proxy_connect
mod_proxy extension for CONNECT request handling
mod_proxy_ftp
FTP support module for mod_proxy
mod_proxy_http
HTTP support module for mod_proxy
mod_proxy_scgi
SCGI gateway module for mod_proxy
mod_reqtimeout
Set timeout and minimum data rate for receiving requests
mod_rewrite
Provides a rule-based rewriting engine to rewrite requested URLs on the fly
mod_setenvif
요청의 성격에 따라 환경변수 설정을 변경한다
mod_so
시작할때 혹은 재시작할때 실행가능한 코드와 모듈을 서버로 읽어들인다
mod_speling
사용자가 대소문자를 잘못 사용하거나 맞춤법이 틀리는 것을 한번까지 허용하여 잘못된 URL을 고치려고 시도한다
mod_ssl
Strong cryptography using the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols
mod_status
서버 활동과 성능에 대한 정보를 제공한다
mod_substitute
Perform search and replace operations on response bodies
mod_suexec
CGI 스크립트를 특정 사용자와 그룹 권한으로 실행한다
mod_unique_id
각 요청마다 유일한 식별자를 가지는 환경변수를 제공한다
mod_userdir
사용자별 디렉토리
mod_usertrack
Clickstream logging of user activity on a site
mod_version
버전별 설정
mod_vhost_alias
Provides for dynamically configured mass virtual hosting
- 주 설정 파일 httpd.conf
- Include 지시자를 통해 conf/extra/ 밑의 필요한 설정 파일들을 포함
- httpd-default.conf: 기본 Timeout, Keepalive 모드 등
# Timeout: The number of seconds before receives and sends time out. Timeout 300 # KeepAlive: Whether or not to allow persistent connections KeepAlive On # MaxKeepAliveRequests: The maximum number of requests to allow # during a persistent connection MaxKeepAliveRequests 100 # KeepAliveTimeout: Number of seconds to wait for the next request from the # same client on the same connection. KeepAliveTimeout 5 # Set to one of: Full | OS | Minor | Minimal | Major | Prod # where Full conveys the most information, and Prod the least. ServerTokens Full
- httpd-info.conf: 서버 Status 및 info
Allow server status reports generated by mod_status, with the URL of http://servername/server-status # Change the ".example.com" to match your domain to enable. <Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from .example.com </Location> # Allow remote server configuration reports, with the URL of http://servername/server-info <Location /server-info> SetHandler server-info Order deny,allow Deny from all Allow from .example.com </Location>
- httpd-mom.conf: 멀티프로세싱 관련
StartServers: initial number of server processes to start # MaxClients: maximum number of simultaneous client connections # MinSpareThreads: minimum number of worker threads which are kept spare # MaxSpareThreads: maximum number of worker threads which are kept spare # ThreadsPerChild: constant number of worker threads in each server process # MaxRequestsPerChild: maximum number of requests a server process serves <IfModule mpm_worker_module> StartServers 2 MaxClients 150 MinSpareThreads 25 MaxSpareThreads 75 ThreadsPerChild 25 MaxRequestsPerChild 0 </IfModule>
- workers.properties
worker.list=jkstatus,edu_wlb worker.template.lbfactor=1 worker.template.type=ajp13 worker.edu_server_11.reference=worker.template worker.edu_server_11.host=192.168.56.101 worker.edu_server_11.port=8009 worker.edu_server_21.reference=worker.template worker.edu_server_21.host=192.168.56.102 worker.edu_server_21.port=8009 worker.edu_wlb.type=lb worker.edu_wlb.method=session worker.edu_wlb.sticky_session=true worker.edu_wlb.balance_workers=edu_server_11,edu_server_21 worker.jkstatus.type=status
- uriworkermap.properties
/*.jsp=edu_wlb /*.do=edu_wlb !/*.jpg=edu_wlb !/*.png=edu_wlb !/*.gif=edu_wlb
- httpd-ssl.conf: ssl 관련
LoadModule ssl_module modules/mod_ssl.so Listen 443 AddType application/x-x509-ca-cert .crt AddType application/x-pkcs7-crl .crl SSLPassPhraseDialog builtin SSLSessionCache shmcb:/var/cache/mod_ssl/scache(512000) SSLSessionCacheTimeout 300 SSLMutex default # Pseudo Random Number Generator (PRNG): SSLRandomSeed startup file:/dev/urandom 256 SSLRandomSeed connect builtin SSLCryptoDevice builtin ## SSL Virtual Host Context NameVirtualHost *:443 <VirtualHost *:443> # General setup for the virtual host, inherited from global configuration DocumentRoot "/var/www/html" ServerName www.rptest1.com:443 ErrorLog /data/logs/apache/rptest1_ssl_error_log LogLevel warn SSLEngine on SSLProtocol all -SSLv2 -SSLv3 #SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5 SSLCertificateFile /etc/pki/tls/certs/localhost.crt SSLCertificateKeyFile /etc/pki/tls/private/localhost.key ... # Per-Server Logging: CustomLog "|/sw/apache/jboss-ews-2.1/httpd/sbin/rotatelogs /data/logs/apache/rptest1.ssl_log.%Y%m%d 86400" \ "%v %{JSESSIONID}C %t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %>s %b" </VirtualHost>
- httpd-vhosts.conf: Virtual host 관련
# Use name-based virtual hosting. # NameVirtualHost *:80 <VirtualHost _default_:80> DocumentRoot "/sw/apache/jboss-ews-2.1/httpd/www" ErrorLog "/data/logs/apache/default_error_log" CustomLog "|/sw/apache/jboss-ews-2.1/httpd/sbin/rotatelogs /data/logs/apache/default.access.log.%Y%m%d 86400" anaysis DirectoryIndex index.html index.jsp JkMount /* wlb JkMount /jkstatus* jkstatus </VirtualHost> <VirtualHost *:80> DocumentRoot "/sw/apache/jboss-ews-2.1/httpd/www" ServerName "www.rptest1.com" ErrorLog "/data/logs/apache/rptest1_error_log" CustomLog "|/svc/test/web/jboss-ews-2.0/httpd/sbin/rotatelogs /data/logs/apache/rptest1.access.log.%Y%m%d 86400" anaysis DirectoryIndex index.html index.jsp JkMount /* wlb JkMount /jkstatus* jkstatus </VirtualHost> <VirtualHost *:80> #DocumentRoot "/svc/test/web/jboss-ews-2.0/httpd/www/html" DocumentRoot "/sw/apache/jboss-ews-2.1/httpd/www" ServerName "www.rptest2.com" ErrorLog "/data/logs/apache/rptest2_error_log" CustomLog "|/svc/test/web/jboss-ews-2.0/httpd/sbin/rotatelogs /data/logs/apache/rptest2.access.log.%Y%m%d 86400" anaysis DirectoryIndex index.html index.jsp JkMount /* wlb JkMount /jkstatus* jkstatus </VirtualHost>
- Apache와 Java Servlet 컨테니어 간에 통신을 지원하는 Apache 모듈
- 주로 Apache 웹 서버와 Tomcat 사이의 연결을 관리하고 Java 웹 어플리케이션에 대한 HTTP 요청을 톰캣으로 전달
- Apache 웹 서버와 Tomcat은 각각의 강점을 살려 성능 최적화
- https://tomcat.apache.org/download-connectors.cgi
- 로드 밸런싱: 어려 대의 tomcat 서버 사이에서 HTTP 요청을 분산 지원
- Apache는 정적 콘텐츠를 tomcat은 동적 콘텐츠를 전달하여 처리할 수 있음
- workers.properties 구성파일을 사용하여 Apache와 Tomcat을 효과적으로 관리
- Load Balancer Configuration Tool 사이트
https://access.redhat.com/labs/lbconfig/