0908
This commit is contained in:
30
nginx/conf.d/00-http.conf
Normal file
30
nginx/conf.d/00-http.conf
Normal file
@@ -0,0 +1,30 @@
|
||||
# HTTP 入口:ACME 验证 + HTTPS 跳转
|
||||
#
|
||||
# 【关键】这个文件必须常驻,且不能引用任何证书文件。
|
||||
# 首次部署时证书尚不存在,如果 nginx 加载了带 ssl_certificate 的 server 块,
|
||||
# 会直接 [emerg] cannot load certificate 退出;而申请证书又必须要有 80 端口可用
|
||||
# —— 形成死锁。因此所有 HTTPS server 块统一放到 /etc/nginx/ssl.d/,
|
||||
# 由 nginx/enable-ssl.sh 在证书就绪后再启用。
|
||||
server {
|
||||
listen 80 default_server;
|
||||
server_name _;
|
||||
|
||||
# 健康检查探针(容器 HEALTHCHECK 使用),不跟随 301
|
||||
location = /healthz {
|
||||
access_log off;
|
||||
default_type text/plain;
|
||||
return 200 "ok\n";
|
||||
}
|
||||
|
||||
# ACME HTTP-01 验证
|
||||
# certbot 通过 webroot 写入 /var/www/certbot/.well-known/acme-challenge/<token>
|
||||
# 该目录是 certbot-webroot 卷,nginx 以只读方式挂载
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/certbot;
|
||||
default_type text/plain;
|
||||
}
|
||||
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user