certbot+nginx (仅用作个人纪录)

本文介绍如何在 CentOS 6 系统中为 Nginx 服务器配置 SSL 证书,实现 HTTPS 访问。通过 Certbot 自动化获取 Let's Encrypt 的免费证书,并设置定时任务进行证书续期。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://certbot.eff.org/#centos6-nginx

https://github.com/kshcherban/acme-nginx

server {
listen 80;

server_name stm.newlook.cn;
root /home/newlook/stm/runtime;

rewrite ^(.*)$ https://$server_name$1 permanent;
access_log /var/log/nginx/host.http2https.access.log
main;

#proxy_cache one;

# location / {
# proxy_set_header X-Forwarded-Host $host;
# proxy_set_header X-Forwarded-Server $host;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_pass http://127.0.0.1:8080/;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
#}

}

 

server {
listen 443 ssl;
listen [::]:443 ssl;
ssl on;
ssl_certificate /etc/letsencrypt/live/stm.newlook.cn/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/stm.newlook.cn/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

server_name stm.newlook.cn;
root /home/newlook/stm/runtime;

#proxy_cache one;

location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

}
history | grep certbot
250 wget https://dl.eff.org/certbot-auto --no-check-certificate
252 yum install certbot
253 certbot certonly
0 0 */28 * * certbot renew --dry-run --pre-hook "service nginx stop" --post-hook "service nginx start"

./certbot-auto certonly --standalone -d puma-iob-staging.system-in-motion.com
crontab -e

0 0 */28 * * ./certbot-auto renew --dry-run --pre-hook "service nginx stop" --post-hook "service nginx start"

puma-iob-staging.system-in-motion.com

转载于:https://www.cnblogs.com/ly-radiata/p/6168717.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值