
IDC 환경에 https로 접속하기 위한 인증서 발급 업무를 맡게되어 certbot를 활용하여 https 인증서를 받는 내용을 정리했습니다.
...
http {
...
server {
...
server_name [도메인]
# Let's Encrypt 인증서 자동 갱신을 위한 설정
location /.well-known/acme-challenge/ {
root /var/www/certbot; # Certbot이 임시 파일을 저장할 위치
allow all;
}
# 모든 HTTP 트래픽을 HTTPS로 리디렉션
location / {
return 301 https://$host$request_uri;
}
}
...
}
version: '3.3'
services:
certbot:
image: certbot/certbot:latest
container_name: cmd_certbot
command: certonly --webroot --webroot-path=/var/www/certbot --email [이메일] --agree-tos --no-eff-email -d [도메인] [--dry-run]
volumes:
- /[path]/certbot/conf:/etc/letsencrypt:rw
- /[path]/certbot/logs:/var/log/letsencrypt:rw
- /[path]/certbot/data:/var/www/certbot:rw
docker-compose -f certbot.yml run --rm certbot
version: '3.3'
services:
nginx:
image: nginx:alpine
container_name: nginx
ports:
- '80:80'
- '443:443'
volumes:
- /[path]/nginx.conf:/etc/nginx/nginx.conf:ro
- /[path]/certbot/data:/var/www/certbot
- /[path]/certbot/conf:/etc/nginx/ssl
restart: always