docs: simpler hackin' example

This commit is contained in:
decentral1se 2024-12-12 23:56:41 +01:00
parent 48abf9ed05
commit 98536f1359
Signed by untrusted user: decentral1se
GPG Key ID: 03789458B3D0C410

View File

@ -52,37 +52,40 @@ Create this Caddyfile in the root of the project repository.
http_port 6565 http_port 6565
} }
http://foo.localhost, http://foo.localhost {
http://bar.localhost {
reverse_proxy { reverse_proxy {
dynamic incus dynamic incus
} }
} }
``` ```
Then run commands based on this example. Then create a new instance and assign the relevant config.
```bash ```bash
incus launch images:alpine/3.20 foo incus launch images:alpine/3.20 foo
incus config set foo user.caddyserver.http.enable=true incus config set foo user.caddyserver.http.enable=true
incus config set foo user.caddyserver.http.matchers.host=foo.localhost incus config set foo user.caddyserver.http.matchers.host=foo.localhost
incus config set foo user.caddyserver.http.upstream.port=80 incus config set foo user.caddyserver.http.upstream.port=80
```
incus launch images:alpine/3.20 bar Serve something from your instance.
incus config set bar user.caddyserver.http.enable=true
incus config set bar user.caddyserver.http.matchers.host=bar.localhost
incus config set bar user.caddyserver.http.upstream.port=80
# wire up a simple web server on your 2 instances ```
# $ incus shell foo / bar incus shell foo
# $ apk add python3 apk add python3
# $ python3 -m http.server 80 python3 -m http.server 80
```
Run Caddy with the plugin baked in.
```
xcaddy run xcaddy run
```
# fire a request via caddy to your instances And finally, route a request to the instance via Caddy.
# curl -X GET http://foo.localhost:6565
# curl -X GET http://bar.localhost:6565 ```
curl -X GET http://foo.localhost:6565
``` ```
🧨 🧨