웹사이트에 HTTPS를 적용하는 것은 이제 선택이 아닌 필수입니다. 검색엔진 순위에도 영향을 미치며, 방문자의 데이터를 안전하게 보호할 수 있습니다. Let’s Encrypt는 무료로 SSL 인증서를 발급해 주는 비영리 인증기관으로, Certbot 도구를 통해 쉽게 적용할 수 있습니다.

사전 준비

  • Nginx가 설치된 Ubuntu/Debian 서버
  • 도메인이 서버 IP로 DNS 연결된 상태
  • 80번, 443번 포트 오픈

Certbot 설치

sudo apt update
sudo apt install -y certbot python3-certbot-nginx

SSL 인증서 발급

sudo certbot --nginx -d example.com -d www.example.com

이메일 주소 입력과 약관 동의 후 자동으로 인증서가 발급되고 Nginx 설정이 수정됩니다.

Nginx 설정 확인

Certbot이 자동으로 수정한 /etc/nginx/sites-available/default 파일을 확인합니다:

server {
    listen 443 ssl;
    server_name example.com www.example.com;

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

    # HTTPS 보안 강화 헤더
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
    add_header X-Frame-Options DENY;
    add_header X-Content-Type-Options nosniff;

    location / {
        root /var/www/html;
        index index.html;
    }
}

# HTTP → HTTPS 리다이렉트
server {
    listen 80;
    server_name example.com www.example.com;
    return 301 https://$host$request_uri;
}

자동 갱신 설정

Let’s Encrypt 인증서는 90일 유효기간을 가집니다. Certbot은 자동 갱신 cron 작업을 등록합니다. 정상 동작 여부를 확인합니다:

sudo certbot renew --dry-run

갱신 cron 작업 확인:

sudo systemctl status certbot.timer

SSL 등급 확인

설정 완료 후 SSL Labs에서 도메인을 검사하면 보안 등급을 확인할 수 있습니다. A+ 등급을 목표로 하세요.

주의사항

  • 서버 IP가 변경되면 DNS 연결을 먼저 수정한 후 인증서를 재발급해야 합니다
  • 발급 한도: 동일 도메인에 주당 5회 제한이 있습니다
  • 와일드카드 인증서(*.example.com)는 DNS 방식으로 별도 발급합니다