Affine behind a traefik v3 reverse proxy, the websocket does not work

Hi everyone,

I'm trying to self-host an AFFiNE instance behind Traefik. When I access it via the local IP (e.g. http://192.168.x.x:3010), everything works perfectly. However, when I route it through Traefik using my domain, the page loads but stays empty – not even the workbook title shows up.

I suspect it has something to do with missing WebSocket configuration, but I'm not sure how to properly set it up in Traefik.

Here are my current labels:

labels:
  - traefik.enable=true
  - traefik.docker.network=forwarding_traefik
  - traefik.http.routers.affine.rule=Host(`${my_url}`)
  - traefik.http.routers.affine.entrypoints=websecure
  - traefik.http.routers.affine.tls=true
  - traefik.http.routers.affine.tls.certresolver=netcup
  - traefik.http.services.affine.loadbalancer.server.port=3010

  # WebSocket support (attempt)
  - traefik.http.middlewares.affine-headers.headers.customrequestheaders.X-Real-IP=true
  - traefik.http.middlewares.affine-headers.headers.customrequestheaders.X-Forwarded-For=true
  - traefik.http.middlewares.affine-headers.headers.customrequestheaders.X-Forwarded-Proto=https
  - traefik.http.middlewares.affine-headers.headers.customrequestheaders.Host=true
  - traefik.http.middlewares.affine-headers.headers.customrequestheaders.Upgrade=$http_upgrade
  - traefik.http.middlewares.affine-headers.headers.customrequestheaders.Connection=upgrade

  - traefik.http.routers.affine.middlewares=affine-headers

Does anyone know what I'm missing or how to properly configure WebSocket support for AFFiNE behind Traefik?

Thanks in advance!
And chatGPT don't know anything :slight_smile:

Usually websocket should just work. You don’t need to mess with the headers, your header config is mostly wrong, and most are set by Traefik automatically anyway.

For others it seems to work without dedicated middleware (link). I would not enable compress, some services are reported here to not work with it.

Thank you, you are right. I think there is another problem in Affine, not in traefik. When I create a new workspace, it works. My other Workspaces from local can't be loaded. Thank you very much. I will try to find out in Affine

Using the labels from this docker compose worked for me