Compare commits

...

7 Commits

Author SHA1 Message Date
w.z
ba9881f45a Merge branch 'caddy_container_example' of https://github.com/comeUpWithItLater/matrix-docker-ansible-deploy into caddy_container_example 2024-09-14 03:47:53 +08:00
w.z
2681f64a3b docs/configuring-playbook-own-webserver-caddy.md removed 2024-09-14 03:43:04 +08:00
w.z
f7fc0a44af README.md updated 2024-09-14 03:39:08 +08:00
w.z
4b917251e8 Code formatted, linted with yamllint 2024-09-14 03:26:00 +08:00
comeUpWithItLater
7cf6cae12d
Update examples/reverse-proxies/caddy2-in-container/README.md
Co-authored-by: Slavi Pantaleev <slavi@devture.com>
2024-09-14 01:53:18 +08:00
comeUpWithItLater
2c9e609b16
Update examples/reverse-proxies/caddy2-in-container/README.md
Co-authored-by: Slavi Pantaleev <slavi@devture.com>
2024-09-14 01:50:56 +08:00
comeUpWithItLater
9d2f0e802a
Update examples/reverse-proxies/caddy2-in-container/README.md
Co-authored-by: Slavi Pantaleev <slavi@devture.com>
2024-09-14 01:43:57 +08:00
3 changed files with 9 additions and 99 deletions

View File

@ -1,90 +0,0 @@
# Using existing Caddy webserver
If you have a server with a Caddy container already serving several applications. And you want to install Matrix on it, but you don't want to break the existing traffic routing (so that the existing applications keep running smoothly). Then this guide is for you.
## Step 1: Config the playbook-managed-traefik
Use configuration like this (as seen in `examples/vars.yml`):
```yaml
##################################### Using your own webserver ###############################################
matrix_playbook_reverse_proxy_type: playbook-managed-traefik
devture_traefik_config_entrypoint_web_secure_enabled: false
devture_traefik_container_web_host_bind_port: '127.0.0.1:81'
devture_traefik_config_entrypoint_web_forwardedHeaders_insecure: true
matrix_playbook_public_matrix_federation_api_traefik_entrypoint_host_bind_port: '127.0.0.1:8449'
```
## Step 2: Config caddy container to cooperate with the playbook-managed-traefik container
Firstly, modify the `docker-compose.yaml` file of caddy's.
```yaml
version: "3.9"
services:
caddy:
image: caddy:2.5.1-alpine
networks:
# add this, so that caddy can talk to the playbook-managed-traefik
- traefik
ports:
- "80:80"
- "443:443"
- "8448:8448"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
# - ./site:/var/www
# other configurations ...
networks:
# add this as well
traefik:
name: traefik
external: true
```
Then config Caddy webserver container to proxy relevant traffic to the playbook-managed-traefik.
Copy the content in `examples/reverse-proxies/caddy2/Caddyfile`, replace localhost and 127.0.0.1 with the relevant docker service name.
```
matrix.example.tld, element.example.tld, etherpadexample.tld, jitsi.example.tld, ntfy.example.tld {
handle {
encode zstd gzip
# reverse_proxy localhost:81 {
reverse_proxy matrix-traefik:8080 { # <- Use the service name here.
header_up X-Forwarded-Port {http.request.port}
# Other configuration ...
}
}
}
# matrix.example.tld:8448 {
https://matrix.example.tld:8448 { # <- Enforce https protocol
handle {
encode zstd gzip
# reverse_proxy 127.0.0.1:8449 {
reverse_proxy matrix-traefik:8448 { # <- Use the service name here.
header_up X-Forwarded-Port {http.request.port}
# Other configurations ...
}
}
}
# Other configurations ...
```

View File

@ -1,20 +1,19 @@
# Caddy reverse-proxy fronting the playbook's integrated Traefik reverse-proxy
This directory contains a sample config that shows you how to front the integrated [Traefik](https://traefik.io/) reverse-proxy webserver with your own container-ed [Caddy](https://caddyserver.com/) reverse-proxy. If you have a server with a Caddy container already serving several applications. And you want to install Matrix on it, but you don't want to break the existing traffic routing (so that the existing applications keep running smoothly). Then this guide is helpful.
This directory contains a sample config that shows you how to front the integrated [Traefik](https://traefik.io/) reverse-proxy webserver with your own **containerized** [Caddy](https://caddyserver.com/) reverse-proxy. If you have a server with a Caddy container already serving several applications and you want to install Matrix on it (with no changes to existing traffic routing), then this guide is for you.
Ps. If you have a `apt-get ` or `yum` installed caddy instead of container-ed Caddy, please see [caddy2](../caddy2/README.md).
Note: if you're running Caddy on the host itself (not in a container), refer to the [caddy2](../caddy2/README.md) example instead.
## Prerequisite configuration
To get started, first follow the [front the integrated reverse-proxy webserver with another reverse-proxy](../../../docs/configuring-playbook-own-webserver.md#fronting-the-integrated-reverse-proxy-webserver-with-another-reverse-proxy) instructions and update your playbook's configuration (`inventory/host_vars/matrix.<your-domain>/vars.yml`).
And adjust the `docker-compose.yaml` of Caddy's. See [examples/reverse-proxies/caddy2-in-container/docker-compose.yaml](./docker-compose.yaml).
Then, adjust your Caddy `docker-compose.yaml` file (if you're using docker-compose for running your Caddy container). See [examples/reverse-proxies/caddy2-in-container/docker-compose.yaml](./docker-compose.yaml).
## Using the Caddyfile
You can either just use the [Caddyfile](Caddyfile) directly or append its content to your own Caddyfile.
In both cases make sure to replace all the `example.tld` domains with your own domain.
This example does not include additional services like element, but you should be able copy the first block and replace the matrix subdomain with the additional services subdomain. I have not tested this though.
This example does not include additional services like Element, but you should be able copy the first block and replace the `matrix.` subdomain with the subdomain of the some other service (e.g. `element.`).

View File

@ -1,10 +1,11 @@
---
version: "3.9"
services:
caddy:
image: caddy:2.5.1-alpine
networks:
# add this, so that caddy can talk to the playbook-managed-traefik
# add this, so that caddy can talk to the playbook-managed-traefik
- traefik
ports:
- "80:80"
@ -12,11 +13,11 @@ services:
- "8448:8448"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
# - ./site:/var/www
# Other configurations ...
# - ./site:/var/www
# Other configurations ...
networks:
# add this as well
traefik:
name: traefik
external: true
external: true