nurikk / zigbee2mqtt-frontend

Zigbee2MQTT frontend
https://www.zigbee2mqtt.io/
GNU General Public License v3.0
263 stars 187 forks source link

[Bug]: Websockets are not accessible behind reverse proxy #2093

Open dfuchss opened 4 months ago

dfuchss commented 4 months ago

What happened?

Hi everyone, I want to place the zigbee2mqtt behind a reverse proxy; i.e., traefik in my case.

My docker-compose configuration defines the connection to the frontend

  zigbee2mqtt:
    image: koenkk/zigbee2mqtt
    restart: always
    expose:
      - "8080"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.zigbee2mqtt-intern.rule=Host(`zigbee2mqtt.my.domain`)"
      - "traefik.http.routers.zigbee2mqtt-intern.entrypoints=websecure"
      - "traefik.http.routers.zigbee2mqtt-intern.tls=true"
      - "traefik.http.routers.zigbee2mqtt-intern.service=zigbee2mqtt"
      - "traefik.http.services.zigbee2mqtt.loadbalancer.server.port=8080"
    environment:
      - TZ=Europe/Berlin
    networks:
      - homeassistant
      - web

I can also connect to the frontend image

For me, the problem is, that the connection to /api (Websocket as far as I can see) fails with response code "302 Found".

image

Interestingly, the problem occurs on Firefox; on my mobile browser (Safari) the /api request works. Does anyone has an idea what the frontend issue might be?

What browsers are you seeing the problem on?

Firefox

Relevant stacktrace

No response

Did you download state.json.zip?

I will not attach state.json.zip

dfuchss commented 4 months ago

What is strange: If I put it behind a path, it works

    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.zigbee2mqtt-intern.rule=Host(`zigbee2mqtt.my.domain`) && (PathPrefix(`/zigbee`) || Path(`/zigbee`))"
      - "traefik.http.routers.zigbee2mqtt-intern.entrypoints=websecure"
      - "traefik.http.routers.zigbee2mqtt-intern.tls=true"
      - "traefik.http.routers.zigbee2mqtt-intern.service=zigbee2mqtt"
      - "traefik.http.services.zigbee2mqtt.loadbalancer.server.port=8080"
      - "traefik.http.routers.zigbee2mqtt-intern.middlewares=zigbee2mqtt-strip"
      - "traefik.http.middlewares.zigbee2mqtt-strip.stripprefix.prefixes=/zigbee"
dfuchss commented 4 months ago

What kind of "works" is the following (it will move the frontend to /zigbee and moves add properly redirects)


    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.zigbee2mqtt-intern.rule=Host(`zigbee2mqtt.my.domain`)"
      - "traefik.http.routers.zigbee2mqtt-intern.entrypoints=websecure"
      - "traefik.http.routers.zigbee2mqtt-intern.tls=true"
      - "traefik.http.routers.zigbee2mqtt-intern.service=zigbee2mqtt"
      - "traefik.http.services.zigbee2mqtt.loadbalancer.server.port=8080"
      - "traefik.http.routers.zigbee2mqtt-intern.middlewares=zigbee-redirect,zigbee2mqtt-strip"
      - "traefik.http.middlewares.zigbee2mqtt-strip.stripprefix.prefixes=/zigbee"
      - "traefik.http.middlewares.zigbee-redirect.redirectregex.regex=^https://zigbee2mqtt.my.domain/$$"
      - "traefik.http.middlewares.zigbee-redirect.redirectregex.replacement=https://zigbee2mqtt.my.domain/zigbee/"```