docs: add info that caddy could be deployed on specific machines

This commit is contained in:
Pasha Sviderski
2025-10-13 20:40:11 +10:00
parent 6ba98e4576
commit dc569175ef
2 changed files with 36 additions and 25 deletions
@@ -9,8 +9,8 @@ with [Let's Encrypt](https://letsencrypt.org/), and route requests to your servi
## How it works ## How it works
Caddy runs as a global service `caddy` on every machine in your cluster, listening on the host ports 80 (HTTP) and 443 By default, Caddy runs as a global service `caddy` on every machine in your cluster, listening on the host ports 80
(HTTPS). (HTTP) and 443 (HTTPS).
It's deployed during cluster initialisation (`uc machine init`) unless you use the `--no-caddy` flag. It's deployed during cluster initialisation (`uc machine init`) unless you use the `--no-caddy` flag.
See [Managing Caddy](3-managing-caddy.md) for deployment and customisation instructions. See [Managing Caddy](3-managing-caddy.md) for deployment and customisation instructions.
@@ -1,7 +1,7 @@
# Managing Caddy # Managing Caddy
Caddy is automatically deployed as a global service `caddy` when you initialise a cluster with `uc machine init`. It Caddy is automatically deployed as a global service `caddy` when you initialise a cluster with `uc machine init`. By
runs on every machine to handle incoming HTTP/HTTPS traffic and route it to your services. default, it runs on every machine to handle incoming HTTP/HTTPS traffic and route it to your services.
## Checking status ## Checking status
@@ -37,6 +37,13 @@ Deploy a specific version or custom image:
uc caddy deploy --image caddybuilds/caddy-cloudflare:2.10.2 uc caddy deploy --image caddybuilds/caddy-cloudflare:2.10.2
``` ```
Deploy only to a specific machine or a subset of machines (comma-separated list):
```shell
uc caddy deploy --machine machine1
uc caddy deploy --machine machine2,machine3,machine4
```
Deploy with custom global configuration: Deploy with custom global configuration:
```shell ```shell
@@ -90,6 +97,10 @@ services:
x-caddy: Caddyfile x-caddy: Caddyfile
deploy: deploy:
mode: global mode: global
# Optional: deploy only to specific machines.
# x-machines:
# - machine1
# - machine2
``` ```
</TabItem> </TabItem>
@@ -98,26 +109,26 @@ services:
```caddyfile ```caddyfile
# Global options. # Global options.
{ {
debug debug
} }
# A snippet that can be reused in custom Caddy configs for services (x-caddy). # A snippet that can be reused in custom Caddy configs for services (x-caddy).
(my_snippet) { (my_snippet) {
... ...
} }
# Obtain a wildcard TLS certificate for all subdomains of example.name using DNS challenge with Cloudflare. # Obtain a wildcard TLS certificate for all subdomains of example.name using DNS challenge with Cloudflare.
# It will be used for services that publish ports with hostnames under example.name. # It will be used for services that publish ports with hostnames under example.name.
*.example.com { *.example.com {
tls { tls {
dns cloudflare {env.CLOUDFLARE_API_TOKEN} dns cloudflare {env.CLOUDFLARE_API_TOKEN}
} }
respond "No host matched" 404 respond "No host matched" 404
} }
# Expose an internal service that is not managed by Uncloud. # Expose an internal service that is not managed by Uncloud.
internal.example.com { internal.example.com {
reverse_proxy 192.168.1.100 reverse_proxy 192.168.1.100
} }
``` ```
@@ -139,8 +150,8 @@ uc deploy
## Verifying config ## Verifying config
View the complete generated Caddyfile served by the `caddy` service. This is useful for debugging and verifying View the complete generated Caddyfile served by the `caddy` service. This is useful for debugging and verifying custom
custom global and service-specific Caddy configs. global and service-specific Caddy configs.
```shell ```shell
uc caddy config uc caddy config
@@ -155,26 +166,26 @@ Example output:
# User-defined global config from service 'caddy'. # User-defined global config from service 'caddy'.
# Global options. # Global options.
{ {
debug debug
} }
# A snippet that can be reused in custom Caddy configs for services (x-caddy). # A snippet that can be reused in custom Caddy configs for services (x-caddy).
(my_snippet) { (my_snippet) {
... ...
} }
# Obtain a wildcard TLS certificate for all subdomains of example.name using DNS challenge with Cloudflare. # Obtain a wildcard TLS certificate for all subdomains of example.name using DNS challenge with Cloudflare.
# It will be used for services that publish ports with hostnames under example.name. # It will be used for services that publish ports with hostnames under example.name.
*.example.com { *.example.com {
tls { tls {
dns cloudflare {env.CLOUDFLARE_API_TOKEN} dns cloudflare {env.CLOUDFLARE_API_TOKEN}
} }
respond "No host matched" 404 respond "No host matched" 404
} }
# Expose an internal service that is not managed by Uncloud. # Expose an internal service that is not managed by Uncloud.
internal.example.com { internal.example.com {
reverse_proxy 192.168.1.100 reverse_proxy 192.168.1.100
} }
# Health check endpoint to verify Caddy reachability on this machine. # Health check endpoint to verify Caddy reachability on this machine.
@@ -210,14 +221,14 @@ https://api.example.com {
# User-defined config for service 'web'. # User-defined config for service 'web'.
www.example.com { www.example.com {
redir https://example.com{uri} permanent redir https://example.com{uri} permanent
} }
example.com { example.com {
reverse_proxy 10.210.0.3:8000 { reverse_proxy 10.210.0.3:8000 {
import common_proxy import common_proxy
} }
log log
} }
# Skipped invalid user-defined configs: # Skipped invalid user-defined configs: