Apache·Nginx·Tomcat 운영 레퍼런스
Apache HTTP Server, Nginx, Tomcat의 역할, 설정 파일, 주요 구성요소, 점검 명령, 장애별 확인 지점을 정리한다.
용도
이 문서는 학습 흐름이 아니라 제품별 참고용이다. 설정 파일 위치, 포트, 명령어, 기본 예시를 빠르게 확인할 때 사용한다.
세부 설명은 제품별 문서에서 확인한다.
역할 비교
| 구분 | 대표 제품 | 주요 역할 | 주 확인 지점 |
|---|
| Web Server | Apache HTTP Server, Nginx | 정적 파일, SSL, Reverse Proxy, Virtual Host | listen 포트, vhost/server block, access/error log |
| Reverse Proxy | Apache mod_proxy, Nginx proxy_pass | 외부 요청을 내부 WAS로 전달 | upstream 주소, proxy header, timeout |
| WAS / Servlet Container | Apache Tomcat | Java 웹 애플리케이션 실행, Servlet/JSP 처리 | Connector, Context, catalina log |
Apache HTTP Server
주요 파일
| 계열 | 경로 예시 |
|---|
| RHEL/CentOS/Rocky | /etc/httpd/conf/httpd.conf, /etc/httpd/conf.d/*.conf |
| Debian/Ubuntu | /etc/apache2/apache2.conf, /etc/apache2/sites-available/, /etc/apache2/sites-enabled/ |
| 로그 | /var/log/httpd/access_log, /var/log/httpd/error_log, /var/log/apache2/access.log, /var/log/apache2/error.log |
주요 모듈
| 모듈 | 역할 |
|---|
mod_ssl | HTTPS 처리 |
mod_proxy | 프록시 기본 모듈 |
mod_proxy_http | HTTP 방식 upstream 프록시 |
mod_proxy_ajp | AJP 방식 Tomcat 연동 |
mod_jk | Tomcat AJP 연동용 별도 커넥터 |
mod_rewrite | URL rewrite/redirect |
mpm_event, mpm_worker, mpm_prefork | process/thread 처리 모델 |
점검 명령
httpd -t
apachectl configtest
systemctl status httpd
systemctl status apache2
ss -lntp
Tomcat 프록시 예시
<VirtualHost *:80>
ServerName example.com
ProxyPreserveHost On
ProxyPass "/" "http://127.0.0.1:8080/"
ProxyPassReverse "/" "http://127.0.0.1:8080/"
ErrorLog logs/example-error.log
CustomLog logs/example-access.log combined
</VirtualHost>
Nginx
주요 파일
| 항목 | 경로 예시 |
|---|
| 메인 설정 | /etc/nginx/nginx.conf |
| 추가 설정 | /etc/nginx/conf.d/*.conf |
| 사이트 설정 | /etc/nginx/sites-available/, /etc/nginx/sites-enabled/ |
| 접근 로그 | /var/log/nginx/access.log |
| 에러 로그 | /var/log/nginx/error.log |
설정 구조
| Context | 역할 |
|---|
main | 전역 설정 |
events | worker process와 connection 처리 |
http | HTTP 전체 설정 |
server | 도메인/포트 단위 가상 서버 |
location | URI 경로별 처리 규칙 |
upstream | 뒤쪽 서버 그룹 |
점검 명령
nginx -t
nginx -s reload
systemctl status nginx
systemctl reload nginx
ss -lntp
Tomcat Reverse Proxy 예시
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Apache Tomcat
구성요소
| 구성요소 | 역할 |
|---|
Server | Tomcat 전체 인스턴스 |
Service | Connector와 Engine을 묶는 단위 |
Connector | 클라이언트 요청 수신. HTTP/AJP 등 |
Engine | Connector에서 받은 요청 처리 파이프라인 |
Host | 도메인/호스트명 단위 가상 호스트 |
Context | 실제 웹 애플리케이션 단위 |
기본 포트
| 포트 | 용도 | 운영 메모 |
|---|
8080 | HTTP Connector | Nginx/Apache 앞단 구성 시 내부 포트로 사용 |
8443 | HTTPS redirectPort 예시 | 실제 HTTPS 처리는 앞단 Web Server에서 하는 경우 많음 |
8005 | shutdown port | 운영 환경에서는 비활성화 또는 로컬 제한 검토 |
8009 | AJP Connector | 외부 노출 금지, 필요 시 secret/address 제한 |
주요 파일과 디렉터리
| 항목 | 설명 |
|---|
conf/server.xml | Connector, Engine, Host 등 서버 구조 설정 |
conf/context.xml | Context 공통 설정 |
conf/web.xml | 웹 애플리케이션 기본 설정 |
webapps/ | WAR 또는 압축 해제된 애플리케이션 배포 위치 |
logs/catalina.out | 표준 출력 로그 |
logs/catalina.YYYY-MM-DD.log | Catalina 로그 |
logs/localhost_access_log.*.txt | Tomcat 접근 로그 |
bin/startup.sh, bin/shutdown.sh | 기동/중지 스크립트 |
bin/setenv.sh | JVM 옵션, 환경변수 분리 설정 |
점검 명령
ps -ef | grep tomcat
systemctl status tomcat
ss -lntp | grep 8080
curl -I http://127.0.0.1:8080
tail -f $CATALINA_BASE/logs/catalina.out
참고 자료