diff --git a/Setup.md b/Setup.md index 42b5bc0..ee1023c 100644 --- a/Setup.md +++ b/Setup.md @@ -8,6 +8,8 @@
  • Nginx Variable
  • Apache
  • Caddy
  • +
  • Caddy V2
  • +
  • Stylus Method
  • @@ -208,6 +210,108 @@ $.getScript('https://archmonger.github.io/Blackberry-Themes/Extras/theme_install }); ``` +### Caddy v2 + +We rely on sjtug's [caddy2-filter](https://github.com/sjtug/caddy2-filter) as Caddy v2 does not have filtering as of now. + +There are two ways to [extend Caddy](https://caddyserver.com/docs/extending-caddy): + +- [Docker](https://hub.docker.com/_/caddy) +- [Bare metal](https://caddyserver.com/docs/download) + +### Docker + +You will have to create your own Caddy image that includes the `caddy2-filter`. + +`Dockerfile`: + +``` +FROM caddy:2.0.0-builder AS builder + +RUN caddy-builder \ + github.com/sjtug/caddy2-filter + +FROM caddy:2.0.0 + +COPY --from=builder /usr/bin/caddy /usr/bin/caddy +``` + +Then run `docker build -t caddy:latest .` to build the image. After we update the `Caddyfile` below, we can (re)start the container by running `docker run -d -p 80:80 -p 443:443 caddy:latest` as an example. + +### Bare metal + +Make sure you install [xcaddy](https://github.com/caddyserver/xcaddy) to add modules to Caddy. + +Then install the `caddy2-filter` module by using: + +```sh +xcaddy build \ + --with github.com/sjtug/caddy2-filter +``` + +You can confirm the module is available by using `xcaddy list-modules`. + +### Updating the `Caddyfile` + +Almost like Caddy v1, here is an example `filter` we need to include in the all the services we want themed: + +``` +filter { + content_type text/html.* + search_pattern + replacement "" +} +``` + +With `caddy2-filter`, we need to also add this option in the global option block: + +``` +{ + order filter after encode +} +``` + +And if you're using a reverse proxy, you also need to include `header_up -Accept-Encoding` in the `reverse_proxy` directive body. + +
    +Full example of a Caddyfile + +``` +{ + order filter after encode +} + +radarr.example.com { + encode zstd gzip + reverse_proxy 127.0.0.1:7878 { + header_up -Accept-Encoding + } + filter { + content_type text/html.* + search_pattern + replacement "" + } +} +``` + +
    + +> :point_right: If your service requires you to ignore a header, use the `header_down` subdirective in the `reverse_proxy` directive. For example, qBittorrent usage would look like this: + +``` +reverse_proxy 127.0.0.1:8080 { + header_up -Accept-Encoding + header_down -x-webkit-csp + header_down -content-security-policy +} +``` + +--- + +Feel free to make any adjustments! Thanks everyone for the help! + +Also for reference: [Caddy v2 structure](https://caddyserver.com/docs/caddyfile/concepts#structure) + # Qbittorrent As Qbittorrent will block the theme with its content security policy you need to change or remove the CSP header.