Skip to content

Commit b6fb468

Browse files
committed
support SAN on certs. scoped down from upstream #83
1 parent 9150c20 commit b6fb468

4 files changed

Lines changed: 14 additions & 1 deletion

File tree

custom-domain/dstack-ingress/DNS_PROVIDERS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This guide explains how to configure dstack-ingress to work with different DNS p
2424
- `SET_CAA` - Enable CAA record setup (default: false)
2525
- `PORT` - HTTPS port (default: 443)
2626
- `TXT_PREFIX` - Prefix for TXT records (default: "_tapp-address")
27+
- `ALIAS_DOMAIN` - An additional domain to include as a Subject Alternative Name (SAN) on the TLS certificate and in nginx `server_name`. When set, the node's certificate covers both `DOMAIN` and `ALIAS_DOMAIN`, and nginx will accept requests for either hostname.
2728

2829
## Provider-Specific Configuration
2930

custom-domain/dstack-ingress/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ configs:
217217
- `PROXY_BUFFERS`: Optional value for nginx `proxy_buffers` (format: `number size`, e.g. `4 256k`) in single-domain mode
218218
- `PROXY_BUSY_BUFFERS_SIZE`: Optional value for nginx `proxy_busy_buffers_size` (numeric with optional `k|m` suffix, e.g. `256k`) in single-domain mode
219219
- `CERTBOT_STAGING`: Optional; set this value to the string `true` to set the `--staging` server option on the [`certbot` cli](https://eff-certbot.readthedocs.io/en/stable/using.html#certbot-command-line-options)
220+
- `ALIAS_DOMAIN` - An additional domain to include as a Subject Alternative Name (SAN) on the TLS certificate and in nginx `server_name`. When set, the node's certificate covers both `DOMAIN` and `ALIAS_DOMAIN`, and nginx will accept requests for either hostname.
220221

221222
**Backward Compatibility:**
222223

custom-domain/dstack-ingress/scripts/certman.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ def _build_certbot_command(self, action: str, domain: str, email: str) -> List[s
288288
if action == "certonly":
289289
base_cmd.extend(["--agree-tos", "--no-eff-email",
290290
"--email", email, "-d", domain])
291+
alias_domain = os.environ.get("ALIAS_DOMAIN", "").strip()
292+
if alias_domain:
293+
base_cmd.extend(["--cert-name", domain, "--expand", "-d", alias_domain])
291294
if os.environ.get("CERTBOT_STAGING", "false") == "true":
292295
base_cmd.extend(["--staging"])
293296

custom-domain/dstack-ingress/scripts/entrypoint.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ fi
4040
if ! TXT_PREFIX=$(sanitize_dns_label "$TXT_PREFIX"); then
4141
exit 1
4242
fi
43+
if ! ALIAS_DOMAIN=$(sanitize_domain "$ALIAS_DOMAIN"); then
44+
exit 1
45+
fi
4346

4447
PROXY_CMD="proxy"
4548
if [[ "${TARGET_ENDPOINT}" == grpc://* ]]; then
@@ -144,11 +147,16 @@ setup_nginx_conf() {
144147
proxy_busy_buffers_size_conf=" proxy_busy_buffers_size ${PROXY_BUSY_BUFFERS_SIZE};"
145148
fi
146149

150+
local server_name_value="${DOMAIN}"
151+
if [ -n "$ALIAS_DOMAIN" ]; then
152+
server_name_value="${DOMAIN} ${ALIAS_DOMAIN}"
153+
fi
154+
147155
cat <<EOF >/etc/nginx/conf.d/default.conf
148156
server {
149157
listen ${PORT} ssl;
150158
http2 on;
151-
server_name ${DOMAIN};
159+
server_name ${server_name_value};
152160
153161
# SSL certificate configuration
154162
ssl_certificate /etc/letsencrypt/live/${cert_name}/fullchain.pem;

0 commit comments

Comments
 (0)