Skip to content

Commit 110c94e

Browse files
author
obsidian
committed
vault backup: 2025-02-11 10:21:36 M source/_posts/nginx-docker-如何更新-letsencrypt-证书.md
Affected files: source/_posts/nginx-docker-如何更新-letsencrypt-证书.md
1 parent 72a39b8 commit 110c94e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

source/_posts/nginx-docker-如何更新-letsencrypt-证书.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,18 @@ sudo docker run -it --rm \
216216
```shell
217217
0 1 * * 0 ~/homepage/certbot/renew.sh
218218
```
219+
220+
注意: 如果是 crontab 定期更新证书,那么需要修改上面的 nginx 配置.以确保非 `/.well-known/acme-challenge/` 请求不会被转发到 https(这时候 https 肯定是不可用的)
221+
```
222+
# 处理 Let's Encrypt 验证请求
223+
location ^~ /.well-known/acme-challenge/ {
224+
allow all;
225+
default_type "text/plain";
226+
root /var/www/$host;
227+
}
228+
229+
# 其他所有请求重定向到 HTTPS
230+
location / {
231+
return 301 https://$host$request_uri;
232+
}
233+
```

0 commit comments

Comments
 (0)