Keycloak behind /auth on Caddy (reverse proxy)

Hey there!
I am a first time Keycloak user, as we are building an online shop for one of our classes. :slightly_smiling_face:
I am using Caddy as my reverse proxy and wanted to have Keycloak’s path to be /auth*.
When I expose /js /realms and /resources on the / path, everything works just fine.

However, when I set Keycloak to be behind /auth/[js*,realms*,resources*], things start to break horribly.
I have set the hostname of keycloak to be https://mydomain.foo/auth as explained here. But all I keep getting is ‘sorry, no page found’ in plain HTML coupled with a lot of 404s.
For reference, I have tried to use both keycloak:24.0 and keycloak:latest to see if this has something to do with a specific release, but that sadly didn’t help much either.
This is my Keycloak config for docker-compose:

services:
  caddy:
    image: caddy:latest
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./site:/usr/share/caddy
      - caddy_data:/data
      - caddy_config:/config
    depends_on:
      - keycloak
    networks:
      - caddy_net
  
  
  keycloak:
    image: quay.io/keycloak/keycloak:latest
    environment:
      KEYCLOAK_ADMIN: admin
      KEYCLOAK_ADMIN_PASSWORD: redacted
      # I have tried it without https:// AND setting the port to :443, which also didn't work.
      KC_HOSTNAME: https://foo.bar/auth  
      KC_HTTP_ENABLED: true
      KC_PROXY: edge # TLS terminated proxy
    networks:
      - caddy_net
    command: start-dev
volumes:
  caddy_data:
  caddy_config:

networks:
  caddy_net:

If anyone here has any idea how to fix this, I would be eternally grateful. :slight_smile:
Thanks in advance you guys!

Try setting http-relative-path=/auth in your config. As an environment variable it is KC_HTTP_RELATIVE_PATH=/auth. It is a build option.