Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be/bugfix/#565 ssl 인증서 만료 #566

Merged
merged 3 commits into from
Feb 23, 2024

Conversation

kimyu0218
Copy link
Collaborator

@kimyu0218 kimyu0218 commented Feb 21, 2024

🔮 resolved #565

변경 사항

  • SSL 인증서 갱신
  • 매월 SSL 인증서를 자동으로 갱신하는 스케줄링 작성
  • 볼륨을 연결하여 SSL 관련 파일 복사 과정 삭제

고민과 해결 과정

1️⃣ SSL 인증서 갱신

net::ERR_CERT_DATE_INVALID 에러를 해결하기 위해 SSL 인증서를 갱신했다. 기존에 작성한 docker-compose의 명령이 올바르지 않아 자동으로 갱신이 이루어지지 않았다.

docker-compose의 커맨드를 수정하는 것도 하나의 방법이지만, 매번 강제로 갱신을 하게 되면 갱신 횟수를 초과할 수 있기 때문에 호스트 서버에 certbot을 설치하여 ssl 인증서를 발급 받았다.

sudo apt install certbot
sudo certbot certonly \
--webroot --webroot-path=/var/www/certbot \
--email [email] \
--agree-tos \
--no-eff-email \ 
-d [domain]

위 명령을 실행하고 나면 /etc/letsencrypt 하위에 keys, live 등이 생긴다.

options-ssl-nginx.confssl-dhparams.pem도 생성하여 보안을 고려해줬다.

sudo openssl dhparam -out /etc/ssl/certs/ssl-dhparams.pem 2048

이제 더 이상 net::ERR_CERT_DATE_INVALID 에러가 발생하지 않는다.

2️⃣ crontab에 SSL 인증서 갱신 등록하기

0 2 1 * * sudo certbot certonly --non-interactive --force-renewal --webroot --webroot-path=/var/www/certbot --email [email] --agree-tos --no-eff-email -d [domain] >> /var/log/certbot-renew.log 2>&1

  • 0 2 1 * * : 매월 1일 오전 2시에
  • sudo certbot ~ : 인증서 갱신하기

--non-interactive로 사용자 입력 없이 실행하고, --force-renewal을 통해 유효기간이 남아있더라도 무조건 갱신하도록 한다.

(선택) 테스트 결과

- push 이벤트가 발생할 때마다 갱신할 것이 아니므로 도커 컴포즈에서 삭제
- 대신 crontab으로 일정기간마다 갱신하도록 수정할 예정
볼륨을 연결하므로 COPY문 필요없음
@kimyu0218 kimyu0218 marked this pull request as ready for review February 21, 2024 16:00
Copy link
Collaborator

@Doosies Doosies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍 👍

@kimyu0218 kimyu0218 merged commit 35289e2 into dev Feb 23, 2024
9 checks passed
@kimyu0218 kimyu0218 deleted the BE/bugfix/#565-SSL-인증서-만료 branch February 23, 2024 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐞 SSL 인증서 만료
3 participants