NGINX 는 이벤트 기반으로 동작하는 웹 서버 · 리버스 프록시 · 로드 밸런서다. 정적 파일과 많은 동시 접속에 강하고, 앞단에서 TLS 를 받아 Tomcat 같은 WAS 로 넘기는 구성에 흔히 쓴다. Apache 와의 비교는 웹 서버 · 웹 애플리케이션 서버 에 있다.
| 계열 | 상태 |
|---|---|
| 1.30.x | stable. 최신 1.30.5[1]. 버그 수정만 |
| 1.31.x | mainline. 최신 1.31.6. 새 기능이 먼저 들어온다 |
배포판 저장소의 nginx 는 오래된 경우가 많으므로 nginx.org 공식 저장소를 쓴다.
sudo dnf install -y yum-utils
/etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=https://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=https://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
mainline 을 쓰려면 sudo yum-config-manager --enable nginx-mainline 으로 바꾼다.
sudo dnf install -y nginx
GPG 키 지문을 물으면 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62 인지 보고 받아들인다.
sudo apt install -y curl gnupg2 ca-certificates lsb-release ubuntu-keyring # Debian 은 debian-archive-keyring
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
지문이 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 인지 본다. stable 저장소를 등록하고 nginx.org 패키지가 배포판 것보다 우선하도록 핀을 건다.
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
https://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
| sudo tee /etc/apt/preferences.d/99nginx
sudo apt update
sudo apt install -y nginx
Debian 은 URL 의 ubuntu 를 debian 으로 바꾼다. mainline 은 packages/mainline/ubuntu 다.
공식 패키지가 nginx.service 를 같이 설치한다. 유닛 파일을 손으로 만들 필요는 없다.
sudo systemctl enable --now nginx
sudo systemctl status nginx
설정을 고친 뒤에는 문법을 검사하고 다시 읽는다.
sudo nginx -t
sudo nginx -s reload
nginx -s 의 시그널은 stop(즉시 종료) · quit(요청 처리 뒤 종료) · reload(설정 재로드) · reopen(로그 파일 재오픈) 이다.
패키지의 기본 경로는 아래와 같다.
| 경로 | 용도 |
|---|---|
/etc/nginx/nginx.conf |
메인 설정 |
/etc/nginx/conf.d/*.conf |
서버 블록. 기본으로 default.conf 가 있다 |
/usr/share/nginx/html |
기본 문서 루트 |
/var/log/nginx/ |
access.log · error.log |
WAS 앞에 두는 리버스 프록시 예다. /etc/nginx/conf.d/app.conf
server {
listen 80;
server_name app.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;
}
}
sudo firewall-cmd --permanent --add-service=http --add-service=https
sudo firewall-cmd --reload
Ubuntu 는 sudo ufw allow 'Nginx Full' 이다.
nginx -v
curl -I http://localhost/
Server: nginx/1.30.5 헤더가 오면 된다.
최신 버전 stable 1.30.5 · mainline 1.31.6 — 2026-09-20 확인. https://nginx.org/en/download.html ↩︎