-
Notifications
You must be signed in to change notification settings - Fork 0
certbot ssl nginx
DaHyeon Won edited this page Dec 23, 2020
·
9 revisions
환경:
OS: Ubuntu 18.04.3 LTS
$ sudo apt-get update # 저장소 업데이트
$ sudo add-apt-repository ppa:certbot/certbot # certbot 저장소 추가
$ sudo apt-get update # 저장소 업데이트
$ sudo apt-get install -y python3-certbot-nginx # certbot 설치
잘 설치되었는지 확인해보자.
$ certbot --version
certbot 0.31.0
$ sudo certbot --nginx
이메일, 약관(a), 메일 수신 여부(n), 도메인(enter), http 통신시 s로 리디렉션 여부(y or 2)를 순서대로 물어본다.
위 과정을 거치면 ssl이 적용된다.
crontab 을 이용해서 갱신 자동화
$ crontab -e
아래 내용을 추가 (매일 오전 5시에 갱신)
0 5 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew
때때로 아래 에러가 발생함.
$ sudo certbot --nginx
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Error while running nginx -c /etc/nginx/nginx.conf -t.
nginx: [emerg] unknown "connection_upgrade" variable
nginx: configuration file /etc/nginx/nginx.conf test failed
The nginx plugin is not working; there may be problems with your existing configuration.
The error was: MisconfigurationError('Error while running nginx -c /etc/nginx/nginx.conf -t.\n\nnginx: [emerg] unknown "connection_upgrade" variable\nnginx: configuration file /etc/nginx/nginx.conf test failed\n',)
solution:
sudo vi /etc/nginx/nginx.conf에 아래 내용을 추가 (map 함수만 추가하면 됨.)
http {
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
location / {
#…
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
}
ref: https://developpaper.com/nginx-emerg-unknown-connection_upgrade-variable-solution-and-thinking/