Reverse-proxy gives a blank screen

1. Caddy version (caddy version):

caddy:latest (2.4.3)

2. How I run Caddy:

I run the docker image through a docker-compose

a. System environment:

Docker on Ubuntu 20.04 Server

b. Command:

None?

c. Service/unit/compose file:

version: "3.5"
services:
  jellyfin:
    image: ghcr.io/linuxserver/jellyfin
    container_name: jellyfin
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Asia/Kolkata
    volumes:
      - /home/junglesucks/config/jellyfin-config:/config
      - /media/serverdata/tv:/data/tvshows
      - /media/serverdata/movies:/data/movies
    ports:
      - 8096:8096
  caddy:
    image: caddy:2.4.3
    container_name: caddy
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
    volumes:
      - $PWD/Caddyfile:/etc/caddy/Caddyfile
      - /home/junglesucks/config/caddy-config:/config
      - /home/junglesucks/data/caddy-data:/data

d. My complete Caddyfile or JSON config:

http://localhost {
  reverse_proxy http://localhost:8096
}

3. The problem I’m having:

When I connect to the host ip from the same network (or even if I curl http://localhost in the server) I get a white screen/blank response.

4. Error messages and/or full log output:

{"level":"info","ts":1628895370.4107208,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"},
{"level":"warn","ts":1628895370.4117415,"msg":"input is not formatted with 'caddy fmt'","adapter":"caddyfile","file":"/etc/caddy/Caddyfile","line":2},
{"level":"info","ts":1628895370.4125645,"logger":"admin","msg":"admin endpoint started","address":"tcp/localhost:2019","enforce_origin":false,"origins":["localhost:2019","[::1]:2019","127.0.0.1:2019"]},
{"level":"info","ts":1628895370.4127584,"logger":"http","msg":"server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server","server_name":"srv0","http_port":80},
{"level":"info","ts":1628895370.4132984,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc0002e2f50"},
{"level":"info","ts":1628895370.414028,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"},
{"level":"info","ts":1628895370.4141593,"msg":"serving initial configuration"},
{"level":"info","ts":1628895370.4142165,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/data/caddy"},
{"level":"info","ts":1628895370.4151764,"logger":"tls","msg":"finished cleaning storage units"},
{"level":"error","ts":1628895872.2538195,"logger":"http.log.error","msg":"dial tcp 127.0.0.1:8096: connect: connection refused","request":{"remote_addr":"172.19.0.1:36142","proto":"HTTP/1.1","method":"GET","host":"localhost","uri":"/","headers":{"Accept":["*/*"],"User-Agent":["curl/7.68.0"]}},"duration":0.000320835,"status":502,"err_id":"39egzrgck","err_trace":"reverseproxy.statusError (reverseproxy.go:857)"}

5. What I already tried:

No idea what I can try

6. Links to relevant resources:

NA

When running in Docker, localhost refers to the current container you’re in. So basically Caddy is trying to connect to a service running in its own container, on port 8096, which doesn’t exist.

Instead, you should use the service name of the container you want to connect to. In this case, jellyfin. Docker runs its own internal DNS server which maps container names to the container’s IP address.

So try this:

http:// {
	reverse_proxy jellyfin:8096
}

Also, using localhost as the site address means that only requests with localhost as the Host header would be matched. Using http:// will let Caddy accept all requests on port 80.

1 Like

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