Let 's Encrypt 무료 https 인증서 신청 실현
5515 단어 오토 메 이 션
certbot 홈 페이지 설치 부분 certbot 홈 페이지 사용 부분 letsencrypt 홈 페이지 nginx 의 기본 배치 부분
certbot 설치
user@webserver:~$ wget https://dl.eff.org/certbot-auto
user@webserver:~$ chmod a+x ./certbot-auto
user@webserver:~$ ./certbot-auto --help
nginx 의 배치
그 중에서 letsencrypt 는 다양한 배치 모델 을 제공 합 니 다. 주요 몇 가지 모델: nginx, webroot, standalone 은 webroot 를 사용 하 는 것 을 권장 합 니 다.nginx 모드 는 nginx 의 프로필 을 업데이트 해 야 합 니 다. 비교적 자동화 되 지만 프로필 을 수정 해서 문제 가 생 길 수 있 습 니 다. 작업 하기 전에 관련 프로필 을 백업 해 야 합 니 다.standalone 모드 는 원래 80 과 443 포트 를 차지 하 는 프로 세 스, 즉 nginx 를 중지 한 후에 야 인증 서 를 신청 할 수 있 습 니 다. 과정 은 네트워크 문제 로 인해 업무 사용 에 영향 을 줄 수 있 습 니 다. 또한 certbot 를 호출 할 때마다 버 전 상황 을 검증 하고 업 데 이 트 를 할 수 있 습 니 다. 업데이트 과정 이 이상 하면 프로 세 스 가 이상 하 게 걸 릴 수 있 습 니 다.업무 사용 에 영향 을 미 칠 수 있 습 니 다.그래서 상대 적 으로 제어 가능 한 웹 루트 모드 를 사용 합 니 다.
구체 적 인 nginx 배치 설명
이 과정 에서 git, python 등 을 사용 해 야 하 며, 이 과정 에서 관련 의존 구성 요소 등 을 설치 해 야 합 니 다.
해당 코드 다운로드
$ sudo apt-get update
$ sudo apt-get install -y git
$ sudo git clone https://github.com/certbot/certbot /opt/letsencrypt
대응 하 는 사이트 디 렉 터 리 를 만 드 는 것 은 간단 한 예 입 니 다. 비 실 용적 인 문 구 는 실제 상황 에 따라 스스로 조정 합 니 다.
$ cd /var/www
$ mkdir letsencrypt
$ sudo chgrp www-data letsencrypt
설정 파일 을 만 들 수 있 습 니 다 (만 들 지 않 고 문 구 를 직접 사용 할 수도 있 습 니 다) 설정 파일 경 로 는 스스로 설정 할 수 있 습 니 다. 뒤의 문 구 를 호출 할 때 조정 / etc / letsencrypt / configs / my - domain. conf
# the domain we want to get the cert for;
# technically it's possible to have multiple of this lines, but it only worked
# with one domain for me, another one only got one cert, so I would recommend
# separate config files per domain.
domains = my-domain
# increase key size
rsa-key-size = 2048 # Or 4096
# the current closed beta (as of 2015-Nov-07) is using this server
server = https://acme-v01.api.letsencrypt.org/directory
# this address will receive renewal reminders
email = my-email
# turn off the ncurses UI, we want this to be run as a cronjob
text = True
# authenticate by placing a file in the webroot (under .well-known/acme-challenge/)
# and then letting LE fetch it
authenticator = webroot
webroot-path = /var/www/letsencrypt/
검사 사이트 만 들 기 (80 포트 를 사용 해 야 합 니 다. 같은 사이트 에서) nginx 설정 파일 은 다음 과 같 습 니 다.
server {
listen 80 default_server;
server_name my-domain;
location /.well-known/acme-challenge {
root /var/www/letsencrypt;
}
# ...
}
이렇게 설정 하면 certbot 는 인증 서 를 생 성 할 때 구체 적 인 경로 에서 방문 합 니 다. 반환 에 따라 사이트 의 합 법성 을 판단 합 니 다. / well - known / acme - challenge 는 폴 더 를 숨 기 고 자동 으로 생 성 되 며 수 동 으로 생 성 할 필요 가 없 지만 certbot 생 성 권한 을 제공 해 야 합 니 다.
완료 후 다시 시작 nginx
sudo nginx -t && sudo nginx -s reload
인증서 생 성 을 신청 합 니 다. 메 일 을 사용 하지 않 으 면 설정 파일 의 메 일 주 소 를 설명 하고 호출 명령 후 인 자 를 추가 할 수 있 습 니 다 – register - unsafely - without - email
$ cd /opt/letsencrypt
$ ./certbot-auto --config /etc/letsencrypt/configs/my-domain.conf certonly
Updating letsencrypt and virtual environment dependencies......
Requesting root privileges to run with virtualenv: /root/.local/share/letsencrypt/bin/letsencrypt --config /etc/letsencrypt/configs/my-domain.conf certonly
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at
/etc/letsencrypt/live/my-domain/fullchain.pem. Your cert
will expire on date. To obtain a new version of the
certificate in the future, simply run Let's Encrypt again.
...
그리고 자동 으로 재 서명 하 는 작업 을 추가 하여 작업 스 크 립 트 를 만 듭 니 다:
#!/bin/sh
cd /workdata/software
echo -e "2
" | ./certbot-auto --config /etc/letsencrypt/configs/wim1.wgamecloud.com.conf certonly --register-unsafely-without-email
if [ $? -ne 0 ]
then
ERRORLOG=`tail /var/log/letsencrypt/letsencrypt.log`
echo -e "The Let's Encrypt cert has not been renewed! n n"
$ERRORLOG
else
/workdata/nginx/sbin/nginx -s reload
fi
exit 0
또한 crontab 에 관련 퀘 스 트 추가
0 0 1 JAN,MAR,MAY,JUL,SEP,NOV * /path/to/renew-letsencrypt.sh
단, 일주일 에 한 번 업데이트 하 는 것 을 권장 합 니 다. lets encrypt 제한 으로 일주일 에 5 번 만 업데이트 할 수 있 습 니 다. 한 인증서 의 유효기간 은 90 일 이 며, 너무 자주 업데이트 하면 업데이트 가 금 지 됩 니 다.
프로 세 스 문제
과정 에서 python 이 Anaconda 라 는 것 을 사용 하면 과정 에서 일부 lib 가 부족 할 수 있 습 니 다. 소프트 연결 을 추가 하고 해당 하 는 lib 를 연결 해 야 합 니 다. 예 를 들 어:
ln -s /root/anaconda3/pkgs/python-2.7.15-h9bab390_2/lib/libpython2.7.so.1.0 /lib64
또한 ImportError: No module named virtualenv 오류 가 발생 할 수 있 습 니 다. yum 설 치 를 통 해 버 전이 너무 낮 아서 새 버 전 을 다시 설치 해 야 합 니 다.
[root@iZ282iltjiwZ https]# yum install python-virtualenv
Loaded plugins: security
Setting up Install Process
Package python-virtualenv-12.0.7-1.el6.noarch already installed and latest version
Nothing to do
wget https://files.pythonhosted.org/packages/33/bc/fa0b5347139cd9564f0d44ebd2b147ac97c36b2403943dbee8a25fd74012/virtualenv-16.0.0.tar.gz
sudo tar zxvf virtualenv-16.0.0.tar.gz
cd virtualenv-16.0.0
python setup.py install
.....
#
Installed /usr/local/python27/lib/python2.7/site-packages/virtualenv-16.0.0-py2.7.egg
Processing dependencies for virtualenv==16.0.0
Finished processing dependencies for virtualenv==16.0.0
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
puppet 의 설치 배치 실례puppet 에 대한 설명 은 여기 서 상세 하 게 소개 하지 않 습 니 다. 여 기 는 주로 puppet 의 설치 방식 과 기본 모듈 의 응용 을 소개 합 니 다.다음은 바로 puppet 배치 설 치 를 시작 하 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.