lovelylain / hass_ingress

Home Assistant ingress feature, add additional ingress panels to your Home Assistant frontend.
Apache License 2.0
73 stars 6 forks source link
custom-component home-assistant ingress

hass_ingress

GitHub actions Buy Me A Coffee

Addons(equivalent containers) for Docker installation

Hass.io provides a very nice feature called Hass.io Ingress, hass_ingress extracts this feature into a standalone integration, it allows you to add additional ingress panels to your Home Assistant frontend. The panels are listed in the sidebar and can contain external resources like the web frontend of your router, your monitoring system, or your media server. Home Assistant will take care of the authentication and the secure connection, so users can access the external resources without extra login.

overview

Features

Install

You can install this custom component by adding this repository (https://github.com/lovelylain/hass_ingress) to HACS in the settings menu of HACS first. You will find the custom component in the integration menu afterwards, look for Ingress. Alternatively, you can install it manually by copying the custom_component folder to your Home Assistant configuration folder.

Configuration

To enable Ingress panels in your installation, add the following to your configuration.yaml file, then restart HA:

ingress:
  link_automation:
    work_mode: iframe
    ui_mode: replace
    title: Automation
    icon: mdi:link
    url: /config/automation/dashboard
  frigate:
    ui_mode: toolbar
    title: Frigate
    icon: mdi:cctv
    url: http://172.30.32.2:5000
  nodered:
    require_admin: true
    title: Node-RED
    icon: mdi:sitemap
    url: http://127.0.0.1:45180
    headers:
      authorization: !secret nodered_auth
  nodered_ui:
    parent: nodered
    title: Node-RED Dashboard
    icon: mdi:monitor-dashboard
    url: http://127.0.0.1:45180
    index: /ui/
    headers:
      authorization: !secret nodered_auth
  openwrt:
    title: OpenWrt
    icon: mdi:router-wireless-settings
    url: http://192.168.0.1/
    headers:
      # auto login for openwrt ingress
      http-auth-user: !secret openwrt_user
      http-auth-pass: !secret openwrt_auth
    # "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/cgi-bin/

After you modify the Ingress configuration, you can go to developer-tools page and click INGRESS to reload without restarting HA.

reload

Configuration variables

_Notice: Not all backend services can be proxied by ingress, it must use relative paths or use X-Ingress-Path http header to generate correct absolute paths. For unsupported backend services, you can try work_mode: auth to work with another domain reverse proxied by nginx, or use nginx's subfilter to fix the absolute paths in the response.

Another option is to use body rewrite rules, see the OpenWrt example above.