lovelylain / hass_ingress

Home Assistant ingress feature, add additional ingress panels to your Home Assistant frontend.
Apache License 2.0
71 stars 6 forks source link

Websocket support #25

Open Dronedale opened 1 month ago

Dronedale commented 1 month ago

My service is using websockets, with ingress it shows me an error. Is it possible to get this working?

lovelylain commented 1 month ago

hass-ingress already supports websocket. For example, nodered uses websocket, which is perfectly compatible with ingress. If there is a problem with your service websocket, it should be due to the service. Each service is different, so please adjust the configuration yourself. If you finally solve it, you are welcome to add the configuration to the document.

Dronedale commented 1 month ago

Thanks for your quick response! Actually I do not really know how to configure ist as I am not that experienced in http stuff. One thing to note if I set work_mode to auth, it is working fine but only using my local ip. Via my nginx reverse proxy I get a blank screen. Leaving work_mode as default (afaik this is ingress) i get this error of my backend (locally as well as with reverse proxy)

image

Dronedale commented 1 month ago

I got the same error message before trying to access the service outside of HA via nginx reverse proxy. The problem got solved there by checking "websockets" in the proxy manager for this host.

Dronedale commented 1 month ago

Also tried to inspect the errors in dev console in google chrome. It says: "WebSocket connection to 'wss:///websockify' failed" when it tries to make a connection in main.bundle.js Any chance to edit the ingress config to get this working?

lovelylain commented 1 month ago

refer to this to try make it work.

    # "fix" absolute URLs by rewriting the response body
    # also disable streaming, or it won't work
    disable_stream: True
    rewrite:
      # for HTML response
      - mode: body
        match: >-
          /(luci-static|cgi-bin)/
        replace: >-
          $http_x_ingress_path/\1/
      # for JS init code
      - mode: body
        match: >-
          \\/(luci-static|cgi-bin|ubus)\\/
        replace: >-
          $http_x_ingress_path\/\1\/
      # for login response
      - mode: header
        name: "(Location|Set-Cookie)"
        match: /cgi-bin/
        replace: $http_x_ingress_path