申請Let's Encrypt 免費通配符 SSL 證書 原

環境

ubuntu16.04

 

下載/安裝/運行

下載 : https://dl.eff.org/certbot-auto

添加權限: chmod a+x certbot-auto

運行: ./certbot-auto certonly  -d "*.weihailan.com" --manual --preferred-challenges dns-01  --server https://acme-v02.api.letsencrypt.org/directory
 

如果出現報錯:

OSError: Command /opt/eff.org/certbot/venv/bin/python2.7 - setuptools pkg_resources pip wheel failed with error code 2

執行下面的操作 : 

sudo apt-get install letsencryp

apt-get purge python-virtualenv python3-virtualenv virtualenv

pip install virtualenv

然後重新執行前一條命令

 

修改 nginx 的配置

運行後 會在 /etc/letsencrypt/live/xxx.com 目錄下生成一些文件,然後添加nginx配置

# 使用 ssl 的站點,自動跳轉和 https 站點的配置
server {
    listen 80;
    server_name xxx.com www.xxx.com;
	
	# 跳轉到 https 站點
	rewrite ^(.*)$ https://$host$1 permanent;
    
	# root /data/wwwroot/xxx;
	# index  index.html;
}

server {
    listen       443 http2 ssl;
    server_name  xxx.com www.xxx.com;
	
	root /data/wwwroot/xxx;
	index  index.html;

    # 啓用 ssl
    ssl on;
	ssl_certificate /etc/letsencrypt/live/xxx.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/xxx.com/privkey.pem;
    ssl_trusted_certificate  /etc/letsencrypt/live/xxx.com/chain.pem;
}

 

最後不要忘了打開443端口供https站點使用

 

普通的 webroot方式可使用命令:

certbot certonly --webroot -d www.xxx.com -w /data/wwwroot/xxx

 

注意:

同 ip 每3小時只允許10個證書的限制

 

更詳細步驟可參考: https://www.hi-linux.com/posts/6968.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章