Skip to content

# Caddy Setup

Laurent Constantin edited this page Aug 17, 2024 · 1 revision

Caddy

Run this project locally (Let's say on port 8083)

On your CaddyFile set the config as below:

books.example.com {
        tls <email>
        reverse_proxy localhost:8083 {
                header_up X-Scheme {scheme}
        }
}

Dev usage of mitmproxy

To official store

  1. Configure your endpoint in your kobo to be different, let's say api_endpoint=https://books-proxy.example.com and restart your Kobo.
  2. Save the mitmproxy script from below:
URL=${1:-https://storeapi.kobo.com}
docker run --rm -it -p 8555:8080 -p 8666:8081 mitmproxy/mitmproxy mitmweb --web-host 0.0.0.0 --mode reverse:$URL
  1. Then setup Caddy as is:
books-proxy.example.com {
        tls <email>
        reverse_proxy http://192.168.1.200:8555 {
                header_down Host
                header_up X-Scheme https
                header_up Host "storeapi.kobo.com"
                header_down X-Forwarded-Proto
                header_down X-Forwarded-Host
                header_down X-Forwarded-For
        }
}
  1. Restart Caddy

To your local env

  1. Run the mitmproxy script above with your local env endpoint ./run.sh https://books.example.com

  2. Edit your Caddy configuration books-proxy.example.com as below, given xxxxx is your KoboDevice access key.

books-proxy.example.com {
        tls <email>
        rewrite * /kobo/xxxxx{uri}

        reverse_proxy http://192.168.1.200:8555 {
                header_down Host
                header_up X-Scheme https
                header_up Host "{upstream_hostport}"
                header_down X-Forwarded-Proto
                header_down X-Forwarded-Host
                header_down X-Forwarded-For
        }
}
  1. Restart Caddy
Clone this wiki locally