Files
common-server-public/nginx/conf.d/00-http.conf
张威33321 fb87be680d 0908
2026-09-08 20:36:17 +08:00

31 lines
1.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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;
}
}