Docker Caddy reverse proxy doesn't seem to be doing anything

1. Output of caddy version:

Docker caddy v2.6.2

2. How I run Caddy:

I am running caddy using Docker Desktop and docker compose

a. System environment:

OS: MacOS
Docker Desktop

b. Command:

uhhhh the docker desktop start arrow?

c. Service/unit/compose file:

version: "3.7"

networks:
        web:
                external: true
        internal:
                external: false
                driver: bridge

services:
        caddy:
                image: caddy:2-alpine
                restart: unless-stopped
                ports:
                        - "80:80"
                        - "443:443"
                volumes:
                        - /Users/zach/CaddyDocker/Caddyfile:/etc/caddy/Caddyfile
                        - /Users/zach/CaddyDocker/data:/data # Optional
                        - /Users/zach/CaddyDocker/config:/config # Optional
                networks:
                        - web
                        - internal

d. My complete Caddy config:

{
    # Global options block. Entirely optional, https is on by default
    # Optional email key for lets encrypt
    email ******@gmail.com 
    # Optional staging lets encrypt for testing. Comment out for production.
    #acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
}
jellyfin.mysite.xyz {
    reverse_proxy 0.0.0.0:8096
}
foundry.mysite.xyz {
    reverse_proxy 0.0.0.0:30000
}

3. The problem I’m having:

The issue I am having is that it seems that the reverse proxy does not do anything.
When I goto mysite.xyz:1234 I am properly directed to my jellyfin server, but that is because I had that set up in the port forwarding options of my router beforehand.
Similarly, if i go to jellyfin.mysite.xyz:1234 I am brought to jellyfin, however if I only go to jellyfin.mysite.xyz I get a “ERR_EMPTY_RESPONSE” from my web browser.

4. Error messages and/or full log output:

Paste logs/commands/output here.
USE THE PREVIEW PANE TO MAKE SURE IT LOOKS NICELY FORMATTED.

Honestly this is my first foray into webhosting and sysadmin, I do not even know where I would find additional information. I am happy to look up whatever I need to, but at the moment I dont know what I dont know!

5. What I already tried:

I have tried a few different solutions like below

jellyfin.mysite.xyz {
    reverse_proxy * 0.0.0.0:8096
}
foundry.mysite.xyz {
    reverse_proxy * 0.0.0.0:30000
}

jellyfin.mysite.xyz {
    reverse_proxy localhost:8096
}
foundry.mysite.xyz {
    reverse_proxy localhost:30000
}

jellyfin.mysite.xyz {
    reverse_proxy * localhost:8096
}
foundry.mysite.xyz {
    reverse_proxy * localhost:30000
}

but they all seem to have the same problems.

6. Links to relevant resources:

Using 0.0.0.0 doesn’t really make sense – that IP address isn’t a real address, it just means “all addresses”. Many HTTP clients end up dialing effectively “localhost” with that though. Using 0.0.0.0 is more useful as a listen address, because it means to listen to all interfaces.

When in Docker, localhost means “this same container”. So trying to reverse_proxy to localhost won’t reach anything, because nothing else is running inside Caddy’s container.

Instead, you need to connect to the other container that’s running your service. Docker has a built-in DNS resolver that lets you connect to other containers by their name. You didn’t show what your other services are in your docker-compose.yml so I can’t tell you what to use, but it should be pretty obvious, just use that service’s name.

1 Like

hi thanks man!
I am trying to grab the foundry server and the jellyfin servers show in the attached screenshot,

can you tell me from here what names I should be using? I am sorry for the basic questions, this is kind of my first foray into docker and networking in general.

should I be using a line more like:

foundry.mysite.xyz{
     reverse_proxy foundryvttdocker
}

or

foundry.mysite.xyz{
     reverse_proxy foundryvttdocker-foundry-1
}

thanks!

Yeah almost, but you need to specify the correct port to use. From that screenshot, it seems like that should be 30000.

Also, you need to have a space after your site address and before the {.

foundry.mysite.xyz {
     reverse_proxy foundryvttdocker:30000
}

well… still no luck.
my caddyfile has been updated to:

but unfortunately still no luck. Is there maybe something I should be doing to the docker-compose file?
thank you again for your help on this!

For docker’s internal DNS to work, Caddy and your other containers need to share a docker network.

You are already using

networks:
  web:
    external: true
  internal:
    external: false
    driver: bridge

so make sure to add either of those networks to jellyfinstuff and foundryvttdocker.


Please also refer from using screenshots to share your Caddyfile, as per the forum rules.
Post it as text in the future. Thank you :innocent:

1 Like

Oops sorry for that!

I have added the web network to the jellyfin compose, but I am still not seeing anything.

version: "3.5"

networks:
        web:
                external: true

services:
  jellyfin:
    image: jellyfin/jellyfin
    container_name: jellyfin
    #user: uid:gid
    #network_mode: "host"
    ports:
      - "8096:8096"
    volumes:
      - /Users/zach/jellyfinStuff/config:/config
      - /Users/zach/jellyfinStuff/cache:/cache
      - /Users/zach/jellyfinStuff/media:/media
      - /Volumes/NAS16tb:/externalMedia
    restart: "unless-stopped"

    networks:
      - web 

I am not sure what I am missing here, thank you for all of your assistance!

You need to elaborate why you mean by

If you see a blank page in your browser, open the network tab in your browsers’ developer console.
You might see a status code != 200


Also, the name in your Caddyfile needs to match the container_name (jellyfin) in your docker-compose.
Or if no container_name is set, it needs to match the service name (in your case also jellyfin)

So assuming you didn’t change your Caddyfile since your last Screenshot, you need to either rename container_name to jellyfinstuff or change reverse_proxy jellyfinstuff:8096 to reverse_proxy jellyfin:8096

Hi Indeed,
You are absolutely correct, I should be more clear.
when i attempt to access jellyfin.mysite.xyz i get a “ERR_EMPTY_RESPONSE” as the error, even after making the change you have mentioned.

However, docker decided to cooperate and let me see the real time logs today, and i noticed a “firewall is probably the problem message” which lead me to realize… I never set up to 80 and 443 port forwarding on my router… genius right here.

Thank you all for your help with this!

1 Like