본문 바로가기
운영체제 및 플랫폼/Linux(리눅스), 우분투(Ubuntu)

Rocky Linux에서 Let's Encrypt로 SSL 인증서 발급 및 NGINX 리버스 프록시 설정 가이드

by upself 2024. 12. 22.
728x90

예시 도메인: upself.tistory.com, upself2.tistory.com

이 가이드는 Rocky Linux 환경에서 Let's Encrypt를 이용해 SSL 인증서를 발급하고, NGINX 리버스 프록시 설정, 그리고 FileMaker Server와 연동하는 실전 절차를 정리한 문서입니다.


1. Certbot 설치 준비

Certbot은 인증서 발급 자동화 도구입니다.

# EPEL 저장소 활성화
sudo dnf install epel-release -y

# Certbot 및 NGINX 플러그인 설치
sudo dnf install certbot python3-certbot-nginx -y

※ Apache 환경이라면 python3-certbot-apache를 설치하세요.


2. 인증서 발급 (단일 도메인)

sudo certbot --nginx -d upself.tistory.com
  • -d 옵션에는 실제 발급받을 도메인을 입력해야 합니다.

3. 인증서 확인

sudo certbot certificates

출력 예시:

Certificate Name: upself.tistory.com
Domains: upself.tistory.com
Expiry Date: 2024-07-01 12:00:00+00:00 (VALID: 89 days)

4. 다중 도메인 (SAN 인증서)

sudo certbot --nginx -d upself.tistory.com -d upself2.tistory.com
  • SAN (Subject Alternative Name) 인증서는 여러 도메인을 하나의 인증서로 관리할 수 있게 해줍니다.

5. NGINX 리버스 프록시 설정 예시

 
# HTTP → HTTPS 리디렉션
server {
    listen 80;
    server_name upself.tistory.com;

    location /.well-known/acme-challenge/ {
        root /var/www/html;
    }

    location / {
        return 301 https://$host$request_uri;
    }
}

# HTTPS 리버스 프록시
server {
    listen 443 ssl;
    server_name upself.tistory.com;

    ssl_certificate /etc/letsencrypt/live/upself.tistory.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/upself.tistory.com/privkey.pem;

    location / {
        proxy_pass https://127.0.0.1:16000;  # FileMaker Admin Console 포트
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

💡 proxy_pass 뒤 IP 및 포트는 FileMaker가 사용하는 포트로 맞춰야 합니다. (예: Admin Console은 16000)


6. 인증서 자동 갱신 설정

# 갱신 테스트
sudo certbot renew --dry-run

Cron 등록 (매일 새벽 3시 자동 갱신 및 NGINX 재시작)

sudo crontab -e
0 3 * * * /usr/bin/certbot renew --quiet && systemctl reload nginx

7. 인증 적용 확인

openssl s_client -connect upself.tistory.com:443 -servername upself.tistory.com

인증서가 정상 설치되었다면 Certificate chain 부분에 발급받은 정보가 출력됩니다. 만약 아래와 같은 오류가 발생한다면:

  • connect: Connection refused
  • Name or service not known

점검 포인트:

  • 도메인이 실제로 DNS에 등록되었는가?
  • nginx -t 로 설정이 올바른지 확인했는가?
  • NGINX를 재시작했는가? (sudo systemctl restart nginx)
  • 443 포트가 방화벽에 열려 있는가?

마무리

이제 Rocky Linux에서 단일 및 다중 도메인에 대한 SSL 인증서를 발급하고, NGINX와 FileMaker Server 연동까지 마친 상태입니다.

💡 인증서 적용 후 반드시 nginx를 재시작하거나 reload 해야 적용됩니다!

반응형