使用 Certbot 获取 Https 证书

使用 Certbot 获取 Https 证书

使用 Certbot 免费获取 Https 证书的三个步骤

安装 Certbot

https://certbot.eff.org/instructions

获取或者重新获取证书

sudo certbot certonly --standalone -d your.domain.com

添加Nginx配置文件

放在 /etc/nginx/conf.d/ 下

upstream app {
server localhost:8080;
}
server {
listen 443;
server_name your.domain.com;
ssl on;
ssl_certificate /etc/letsencrypt/live/your.domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your.domain.com/privkey.pem;

location / {
proxy_pass http://app;
proxy_http_version 1.1;
proxy_set_header X_FORWARDED_PROTO https;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
}
server {
listen 80;
server_name your.domain.com;
rewrite ^(.*)$ https://${server_name}$1 permanent;
}

`

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×