CentOS 7에서 Nginx VTS(nginx-module-vts) 모듈을 추가하는 방법
필요한 패키지 설치
sudo yum install -y epel-release
sudo yum install -y gcc gcc-c++ make openssl-devel pcre-devel zlib-devel git wget
작업 디렉토리로 이동
cd /usr/local/src
Nginx 소스 다운로드
wget https://nginx.org/download/nginx-1.24.0.tar.gz
tar -xzf nginx-1.24.0.tar.gz
VTS(nginx-module-vts) 모듈 소스 다운로드
git clone https://github.com/vozlt/nginx-module-vts.git
Nginx 컴파일 설정
- Nginx 소스 디렉터리로 이동 후 --add-module 옵션으로 VTS 모듈을 추가합니다.
더보기
---
./configure --with-compat --add-dynamic-module=../nginx-module-vts
---
cd /usr/local/src/nginx-1.24.0
./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--add-module=/usr/local/src/nginx-module-vts
컴파일 및 설치
make && sudo make install
nginx 버전 정보 확인 및 vts 모듈 확인
nginx -V
Nginx 설정에 VTS 모듈 추가
- server 블록 안에 vhost_traffic_status_zone; 추가
vim /etc/nginx/nginx.conf
# nginx.conf
user www-data www-data;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
vhost_traffic_status_zone;
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;
...
}
가상호스트 설정
vim /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
location /status {
vhost_traffic_status_display;
vhost_traffic_status_display_format html;
}
}
Nginx 재시작 및 확인
sudo nginx -t
sudo systemctl restart nginx
이제 nginx-module-vts 모듈이 Nginx에 추가되었으며 설정 파일에서 활용할 수 있습니다.
서비스 등록
sudo tee /etc/systemd/system/nginx.service <<'EOF'
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=network.target
[Service]
ExecStart=/usr/sbin/nginx -g 'daemon off;'
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PIDFile=/var/run/nginx.pid
Restart=always
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable nginx
sudo systemctl start nginx
./configure --with-compat --add-dynamic-module=../nginx-module-vts
'리눅스' 카테고리의 다른 글
[draft] ICMP Ping 테스트를 수행하는 Python 스크립트 (0) | 2025.10.17 |
---|---|
[draft] CentOS 7에서 OpenSSL과 keytool로 JKS 키스토어 생성하는 방법 (0) | 2025.10.17 |
[draft] ipcalc 명령어 (0) | 2025.10.17 |
[draft] nmap 명령어 (0) | 2025.10.16 |
[draft] nc 명령어 - 사용 예시 (0) | 2025.10.16 |