0단계 — 서버 확인 (모든 조치 공통)
① 서버 접속 — SSH 로 접속한다. 계정에 sudo 권한이 필요하다.
② 웹서버 타입·버전 확인
ps -ef | grep -E 'nginx' | grep -v grep # nginx 프로세스 확인
nginx -v # 버전 (예: nginx/1.24.0)
nginx -V 2>&1 | tr ' ' '\n' | grep -i openssl # OpenSSL 버전 — TLS 1.3 가능 여부
- TLS 1.3 은 nginx 1.13.0 이상 + OpenSSL 1.1.1 이상 둘 다 필요하다 (ssl_protocols 공식 문서의
TLSv1.3 (1.13.0)표기)
③ 설정 파일 위치 찾기
nginx -t # 설정 루트가 출력됨 (보통 /etc/nginx/nginx.conf)
nginx -T | grep -n "ssl_certificate\|ssl_protocols\|server_name" # 현재 적용값 전체 덤프
nginx -T 가 실제로 로드되는 설정의 전부다. include 가 얽혀 있어도 이걸 보면 어느 파일의 어느 줄인지 나온다.
④ 인증서 경로 확인 — ③의 ssl_certificate / ssl_certificate_key 값이 현재 사용 중인 파일 경로다.
TLS 1.0/1.1 비활성 + TLS 1.3 활성
해당 도메인의 server 블록(443)에서:
ssl_protocols TLSv1.2 TLSv1.3; # 1.0·1.1 제거, 1.3 활성
OpenSSL 이 1.1.1 미만이라 TLS 1.3 이 안 되면 우선 TLSv1.2 만이라도:
ssl_protocols TLSv1.2;
적용 확인:
openssl s_client -connect 도메인:443 -tls1_1 </dev/null 2>&1 | grep -q "handshake failure\|no protocols" && echo "1.1 차단 OK"
보안 헤더 (HSTS·CSP·nosniff·클릭재킹·Referrer)
server 블록(443)에:
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# CSP 는 사이트 구조에 맞춰 조정 — 우선 Report-Only 로 관찰 후 강제 권장
add_header Content-Security-Policy "default-src 'self'" always;
HTTP → HTTPS 리다이렉트
80 포트 server 블록을 다음으로 교체:
server {
listen 80;
server_name 도메인;
return 301 https://$host$request_uri;
}
인증서 교체가 필요한 경우 (약한 키·서명)
RSA 2048 미만 또는 SHA-1 서명이면 재발급이 답이다 — Nginx 인증서 교체와 무중단 리로드 절차를 따를 것.
신규 도메인 인증서 설치
발급·파일 준비는 발급 공통 가이드 먼저.
① 파일 배치 — /etc/nginx/ssl/ 등에 fullchain·개인키 배치, 개인키 chmod 600.
② server 블록 추가 — conf.d/새도메인.conf:
server {
listen 443 ssl;
http2 on; # 1.25.1+ (이전 버전: listen 443 ssl http2;)
server_name 새도메인;
ssl_certificate /etc/nginx/ssl/fullchain.pem; # leaf+중간 — fullchain 필수
ssl_certificate_key /etc/nginx/ssl/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
# ... root/proxy 설정
}
server {
listen 80;
server_name 새도메인;
return 301 https://$host$request_uri;
}
③ 확인 — openssl s_client -connect 새도메인:443 -servername 새도메인 또는 진단 툴. -verify_return_error 가 0 (ok) 인지 — fullchain 누락이 여기서 걸린다.
최종 확인
진단 툴에 도메인을 넣어 등급이 올라갔는지 확인한다. 검사 결과는 최대 10분 캐시된다.
참조 문서 (공식)
- ngx_http_ssl_module — ssl_protocols·ssl_certificate
- ngx_http_headers_module — add_header 상속 규칙 원문: “These directives are inherited from the previous configuration level if and only if there are no add_header directives defined on the current level.”
- ngx_http_v2_module — http2 지시자 (1.25.1)