From 8eca961a57036a4a9e91e4c510adb282174ab613 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Tue, 21 May 2024 17:06:22 +0200 Subject: [PATCH] feat: add caddy config files --- caddy/README.md | 12 ++++++++++++ caddy/caddy/Caddyfile | 24 ++++++++++++++++++++++++ caddy/systemd/caddy.service | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 caddy/README.md create mode 100644 caddy/caddy/Caddyfile create mode 100644 caddy/systemd/caddy.service diff --git a/caddy/README.md b/caddy/README.md new file mode 100644 index 0000000..2841b51 --- /dev/null +++ b/caddy/README.md @@ -0,0 +1,12 @@ +# Configuration de `caddy` + +Reverse proxy pour cohabit. + +## Port + +`localhost:80` `localhost:443` + +## Emplacements + +- `./caddy/*` -> `/etc/caddy/*` +- `./systemd/*` -> `/etc/systemd/system/*` diff --git a/caddy/caddy/Caddyfile b/caddy/caddy/Caddyfile new file mode 100644 index 0000000..e713b89 --- /dev/null +++ b/caddy/caddy/Caddyfile @@ -0,0 +1,24 @@ +localhost:80, +cohabit.fr { + # Website entry point + + encode zstd gzip + reverse_proxy 127.0.0.1:8000 +} + +www.cohabit.fr { + # Redirect "www" subdomain to main website entry point + redir https://cohabit.fr{uri} permanent +} + +git.cohabit.fr { + # Forgejo instance for cohabit + + reverse_proxy 127.0.0.1:10001 +} + +projets.cohabit.fr { + # Redmine instance for cohabit + + reverse_proxy 127.0.0.1:33037 +} diff --git a/caddy/systemd/caddy.service b/caddy/systemd/caddy.service new file mode 100644 index 0000000..28d92f1 --- /dev/null +++ b/caddy/systemd/caddy.service @@ -0,0 +1,35 @@ +# caddy.service +# +# For using Caddy with a config file. +# +# Make sure the ExecStart and ExecReload commands are correct +# for your installation. +# +# See https://caddyserver.com/docs/install for instructions. +# +# WARNING: This service does not use the --resume flag, so if you +# use the API to make changes, they will be overwritten by the +# Caddyfile next time the service is restarted. If you intend to +# use Caddy's API to configure it, add the --resume flag to the +# `caddy run` command or use the caddy-api.service file instead. + +[Unit] +Description=Caddy +Documentation=https://caddyserver.com/docs/ +After=network.target network-online.target +Requires=network-online.target + +[Service] +Type=notify +User=caddy +Group=caddy +ExecStart=/usr/local/bin/caddy run --environ --config /etc/caddy/Caddyfile +ExecReload=/usr/local/bin/caddy reload --config /etc/caddy/Caddyfile --force +TimeoutStopSec=5s +LimitNOFILE=1048576 +PrivateTmp=true +ProtectSystem=full +AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE + +[Install] +WantedBy=multi-user.target