서버 설정 · 2 min read · Feb 08, 2026

RHEL 5.2에서 Nginx로 Apache의 부하 줄이기

RHEL 5.2에서 Nginx로 Apache의 부하 줄이기

이 방법서는 RHEL 5.2 기반의 Apache 서버를 가속화하기 위해 Nginx를 설치하고 구성하는 방법을 설명합니다.

1. 설치된 패키지 업데이트

yum install update

2. 새 패키지 설치

yum install -y httpd-devel
wget http://rpmfind.net/linux/EPEL/5Server/i386/nginx-0.6.31-3.el5.i386.rpm
rpm nginx-0.6.31-3.el5.i386.rpm

3. /etc/nginx/nginx.conf 편집

Nginx를 리버스 프록시로 설정:

nano /etc/nginx/nginx.conf

worker_processes 1;를 worker_processes 2;로 변경;

다음으로 교체:

http {
  include /etc/nginx/mime.types;
  default_type application/octet-stream;
  log_format main '$remote_addr - $remote_user [$time_local] $request '
  '"$status" $body_bytes_sent "$http_referer" '
  '"$http_user_agent" "$http_x_forwarded_for"';
  access_log /var/log/nginx/access.log main;
  sendfile on;
  #tcp_nopush on;
  #keepalive_timeout 0;
  keepalive_timeout 65;
  #gzip on;

# /etc/nginx/conf.d 디렉토리에서 구성 파일 로드
 include /etc/nginx/conf.d/*.conf;
#
# 기본 서버
#
server {
listen 80;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}

다음으로:

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
gzip on;
# /etc/nginx/conf.d 디렉토리에서 구성 파일 로드
include /etc/nginx/conf.d/*.conf;
#
# 기본 서버
#
server {
listen 80;
server_name YOURSERVERNAME;
#charset koi8-r;
#access_log logs/host.access.log main;
#주 위치
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_redirect off;
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_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
root /usr/share/nginx/html;
index index.html index.htm index.php;
}

이 기능은 Nginx가 다음 파일 형식과 함께 작동할 수 있도록 합니다:

다음으로 변경:

#location ~ \/\.ht {
#deny all;

다음으로:

location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|wav|bmp|rtf|js)$ {root /var/www;}

4. nginx conf 확인

nginx -t

결과는 다음과 같아야 합니다:

2008/07/17 16:09:46 [info] 17197#0: 구성 파일 /etc/nginx/nginx.conf 구문이 올바릅니다
2008/07/17 16:09:46 [info] 17197#0: 구성 파일 /etc/nginx/nginx.conf가 성공적으로 테스트되었습니다

5. rpaf-2.0 모듈 설치

이 모듈은 Apache에 활성 Nginx IP를 제공합니다.

cd /usr/local/src
wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
tar xzf mod_rpaf-0.6.tar.gz
cd mod_rpaf-0.6

rpaf 모듈 컴파일:

nano /usr/local/src/mod_rpaf-0.6/makefile

APXS=$(shell which apxs)를 APXS=/usr/sbin/apxs로 변경.

컴파일 방법:

I)

make rpaf-2.0 && make install-2.0

II)

apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c

6. httpd.conf 편집

nano /etc/httpd/conf/httpd.conf

다음 추가:

...
LoadModule rpaf_module modules/mod_rpaf-2.0.so
....

#Mod_rpaf 설정
RPAFenable On
RPAFproxy_ips 127.0.0.1 REALIP1 REALIP2
RPAFsethostname On

Listen 80을 Listen 8080으로 변경, Nginx가 포트 80을 사용하기 때문입니다.

7. Apache 재시작 및 Nginx 시작

service httpd restart
service nginx start

8. 결과 보기

Nginx에 의한 Apache 테스트 페이지:

Share: X/Twitter LinkedIn

새 게시물을 받은 편지함에서 받기

스팸은 없습니다. 언제든지 구독 해지 가능합니다.