How can I forward basic auth from caddy to my application?

  1. Caddy version (caddy version): v2.4.5

2. How I run Caddy:

I am running caddy in docker compose

a. System environment:


d. My complete Caddyfile or JSON config: {
    respond "btc litenode server is running"
} {
    handle_path /tbtc {
        reverse_proxy * electrum_testnet:7000

    handle /ttbtc {
        uri strip_prefix /ttbtc
        reverse_proxy * electrum_testnet:7000

    handle_path /ping {
        respond "Pong!"

3. The problem I’m having:

electrum requires basic authentication but it seems that caddy is not forwarding the auth details to it. electrum returns Unauthorized while it is supposed to return forbidden if the auth is not currect.

5. What I already tried:

I have tried changing reverse_proxy * electrum_testnet:7000 to reverse_proxy * http://username:password@electrum_testnet:7000 but it still didn’t work

Can you verify this by inspecting the headers? (Enable debug logging.)

I was able to fix it by inspecting the logs. My request contains an authorization header which overrides the basic auth.

Thanks for the suggestion

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.