Two beginner questions: immich and file serving

Note that I’ve redacted my domain names here … but I can replace them with the correct names if needed.

1. The problem I’m having:

I have two problems:

  1. I’m trying to run immich, but I can’t get it working. My caddyfile block is
immich.mysite.net:443 {
	reverse_proxy immich:2283
}

I’ve also tried with port 3001. However, neither work, all I’m getting is a message that “The page isn’t working”, with http error 502.

  1. I’m also trying to serve my blog, which is a static web site (I use Hugo for it). I want to protect it, of course, with https. But this isn’t sufficient:
mysite.net:443 {
        root * /home/me/Docker/blog
	file_server
}

The “index.html” file is in the directory shown.

2. Error messages and/or full log output:

docker logs caddy, when trying to access immich:

{"level":"error","ts":1714030809.612247,"logger":"http.log.error","msg":"dial tcp: lookup immich on 127.0.0.11:53: no such host","request":{"remote_ip":"157.211.238.17","remote_port":"42068","client_ip":"157.211.238.17","proto":"HTTP/3.0","method":"GET","host":"immich.numbersandshapes.net","uri":"/","headers":{"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"],"Sec-Ch-Ua-Mobile":["?0"],"Sec-Fetch-Site":["none"],"Accept-Language":["en-GB,en-US;q=0.9,en;q=0.8"],"Sec-Ch-Ua-Platform":["\"Linux\""],"Sec-Fetch-User":["?1"],"Accept-Encoding":["gzip, deflate, br"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"],"Sec-Ch-Ua":["\"Not_A Brand\";v=\"8\", \"Chromium\";v=\"120\", \"Google Chrome\";v=\"120\""],"Sec-Fetch-Mode":["navigate"],"Sec-Fetch-Dest":["document"],"Upgrade-Insecure-Requests":["1"],"Cookie":[]},"tls":{"resumed":false,"version":772,"cipher_suite":4867,"proto":"h3","server_name":"immich.numbersandshapes.net"}},"duration":0.003106129,"status":502,"err_id":"4andu2mxy","err_trace":"reverseproxy.statusError (reverseproxy.go:1267)"}

When trying to access my blog I get an http error 404.

3. Caddy version:

I’m using docker compose, and I’ve specifically used version 2.7.6.

4. How I installed and ran Caddy:

Using docker and docker compose. Up until recently, I used SWAG as my reverse proxy (it’s basically a front end to nginx plus a few extras), but I want to shift to caddy to support an app still in development, which doesn’t work with nginx. The relevant parts of my docker_compose_caddy.yml file are:

services:
  caddy:
    container_name: caddy
    image: caddy:2.7.6
    restart: always
    ports:
      - "80:80"
      - "443:443"
      - "443:443/udp"
    networks:
      - caddy_net
    volumes:
      - /home/me/Docker/Caddy/Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config

networks:
  caddy_net:
    external: true
    name: caddy_net

volumes:
  caddy_data:
  caddy_config:

a. System environment:

Ubuntu 20.04LTS; docker 25.0.1, docker compose 2.24.2

b. Command:

First to start the containers, or restart them if I’ve made any changes to the docker compose file:

docker compose -f docker_compose_caddy.yml up -d

and if I make any changes to the Caddyfile:

docker restart caddy

or

docker compose exec -w /etc/caddy caddy caddy reload

I’m doing everything with docker compose.

c. Service/unit/compose file:

Is above enough?

d. My complete Caddy config:

{
	email <my email>
}

# mealie is working
mealie.mysite.net {
	reverse_proxy mealie:9000
}

# portainer is now working
portainer.mysite.net {
	reverse_proxy portainer:9000
}

# adminer is working
adminer.mysite.net:443 {
	reverse_proxy adminer:8080
}

# not yet working
immich.mysite.net:443 {
	reverse_proxy immich:2283
}

# blog not yet working
mysite.net:443 {
	root * /home/me/Docker/blog
	file_server
}

All the subdomains have an A record defined with my name hosting service (who also provide DNS).

5. Links to relevant resources:

Possibly not relevant

I hope that’s enough information! I’ve done quite a bit of reading, on the Caddy site as well as elsewhere, but something is still eluding me. Many thanks!

This means Docker’s DNS resolver isn’t able to give you an IP address for the name immich. Are you sure that’s the name of the immich container? Are you sure it’s in the same network as Caddy?

You need to mount your files into your Caddy container somewhere. Use a volume to do that. Caddy is running inside Docker, so it’s isolated from the host, it can’t see any files on the host machine.

I recommend mounting your files to /srv or /srv/blog or whatever.

You don’t need :443 on your site addresses, it’s redundant. Caddy defaults to HTTPS when given a valid domain, and HTTPS is on port 443.

1 Like

Thank you very much! I’m still wrestling with immich, but I can at last see my blog - my problem (as you see) was putting the local file in the Caddyfile block, instead of the Caddy directory. I now have

mysite.net {
	root * /srv
	file_server
}

accompanied by an appropriate bind mount in my docker compose file, and it’s working.

1 Like