### URL Rewriting Example Source: https://github.com/lovelylain/hass_ingress/blob/main/README.md A practical example demonstrating how to use 'match', 'replace', and 'default' for URL rewriting to handle different network access scenarios. ```yaml match: (\w+://)hass(\..+) replace: $1openwrt$2 default: https://openwrt.example.com ``` -------------------------------- ### Docker Compose - Complete Setup Source: https://context7.com/lovelylain/hass_ingress/llms.txt Deploy Home Assistant with ingress-enabled services in Docker without Hassio Supervisor. This provides a self-contained environment for Home Assistant and its related services. ```APIDOC ## Docker Compose - Complete Setup Deploy Home Assistant with ingress-enabled services in Docker without Hassio Supervisor. ```yaml # docker-compose.yml name: ha networks: default: driver: bridge driver_opts: com.docker.network.bridge.name: hassio ipam: config: - subnet: 172.30.32.0/23 ip_range: 172.30.33.0/24 gateway: 172.30.32.1 services: dns: image: nginx restart: always networks: default: ipv4_address: 172.30.32.3 volumes: - ./nginx/dns_proxy.conf:/etc/nginx/nginx.conf homeassistant: image: homeassistant/home-assistant restart: always privileged: true network_mode: host dns: [172.30.32.3] dns_opt: ["ndots:0"] volumes: - /run/dbus:/run/dbus:ro - ./homeassistant:/config nodered: image: nodered/node-red restart: unless-stopped volumes: - ./node-red:/data vscode: image: linuxserver/code-server restart: unless-stopped environment: - PUID=0 - PGID=0 volumes: - ./vscode:/config - .:/data ``` ``` -------------------------------- ### Run Home Assistant and Node-RED with Docker Compose Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md This command sequence initializes the Home Assistant environment, sets up the necessary directories, and starts Home Assistant and Node-RED using Docker Compose. It includes steps for configuring Home Assistant to access Node-RED via its sidebar. ```shell mkdir -p /opt/hassio cd /opt/hassio vim docker-compose.yml # see content below mkdir nginx node-red vim nginx/dns_proxy.conf # see content below chown 1000:1000 node-red docker compose up -d # Access http://local_ip:8123/ to configure homeassistant # Install Ingress integration in homeassistant vim homeassistant/configuration.yaml # add content below docker compose restart homeassistant # Now you can access Node-RED from HA's sidebar. If you want add new addons, # add service in docker-compose.yml then `docker compose up -d` # add ingress in configuration.yaml then reload INGRESS. ``` -------------------------------- ### Complete Docker Compose Setup for Home Assistant with Ingress Source: https://context7.com/lovelylain/hass_ingress/llms.txt Deploy Home Assistant and ingress-enabled services using Docker Compose without Hassio Supervisor. Configures networking and service volumes. ```yaml # docker-compose.yml name: ha networks: default: driver: bridge driver_opts: com.docker.network.bridge.name: hassio ipam: config: - subnet: 172.30.32.0/23 ip_range: 172.30.33.0/24 gateway: 172.30.32.1 services: dns: image: nginx restart: always networks: default: ipv4_address: 172.30.32.3 volumes: - ./nginx/dns_proxy.conf:/etc/nginx/nginx.conf homeassistant: image: homeassistant/home-assistant restart: always privileged: true network_mode: host dns: [172.30.32.3] dns_opt: ["ndots:0"] volumes: - /run/dbus:/run/dbus:ro - ./homeassistant:/config nodered: image: nodered/node-red restart: unless-stopped volumes: - ./node-red:/data vscode: image: linuxserver/code-server restart: unless-stopped environment: - PUID=0 - PGID=0 volumes: - ./vscode:/config - .:/data ``` -------------------------------- ### URL Rewriting Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/README.md Example of extended URL configuration for matching and replacing URL patterns. Useful for handling different internal and external access URLs. ```yaml url: match: JS regular expression to match scheme://host[:port]. replace: JS regular replacement to build real url. default: Default url when regular expression does not match. ``` -------------------------------- ### MQTT Addon Docker Compose Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md Configure the MQTT Mosquitto addon using Docker Compose. This setup uses a go-auth plugin for authentication. ```yaml name: ha services: mqtt: image: iegomez/mosquitto-go-auth restart: always environment: - TZ=Asia/Shanghai volumes: - ./mosquitto:/etc/mosquitto ``` -------------------------------- ### Static Token Access Source: https://github.com/lovelylain/hass_ingress/blob/main/README.md Example of using a static token for accessing backend services without requiring HA login. The access link will not expire. ```string /api/ingress/t-a-secret-token-value/ ``` -------------------------------- ### Configure Static Token for Ingress Access Source: https://github.com/lovelylain/hass_ingress/blob/main/README.md Enable static token feature to access backend services without logging into HA. The token is appended to the `/api/ingress/` path. Example shows configuration for ttyd and nodered_webhook. ```yaml ingress: ttyd: # you can access ttyd with /api/ingress/t-secret-token-value-for-ttyd/ without login. work_mode: ingress title: Terminal url: static_token: secret-token-value-for-ttyd nodered_webhook: # you can access ttyd with /api/ingress/t-secret-token-value-for-nodered_webhook/ without login. parent: nodered work_mode: ingress url: static_token: secret-token-value-for-nodered_webhook ``` -------------------------------- ### Configure User Info Headers in Ingress Source: https://github.com/lovelylain/hass_ingress/blob/main/README.md Starting from v1.3.0, user information can be used in headers. The `$user_id`, `$user_name`, and `$username` variables can be used to inject user-specific details into request headers. ```yaml ingress: foobar: headers: # $user_id is user.id # $user_name is Name of user # $username is user login name Remote-User: $username ``` -------------------------------- ### Configure Hass Ingress Panels Source: https://github.com/lovelylain/hass_ingress/blob/main/README.md Add this configuration to your `configuration.yaml` to enable and customize Ingress panels for various services. Restart Home Assistant after modifying the configuration. ```yaml 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 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/ ``` -------------------------------- ### Configure Basic Ingress Panels in YAML Source: https://context7.com/lovelylain/hass_ingress/llms.txt Define ingress panels in configuration.yaml to proxy backend services. Supports different UI modes and custom authentication headers. ```yaml ingress: # Basic ingress panel - proxies requests to backend service frigate: title: Frigate icon: mdi:cctv url: http://172.30.32.2:5000 work_mode: ingress # default mode - full proxy ui_mode: toolbar # show HA header on panel page # Admin-only panel with custom authentication headers nodered: require_admin: true title: Node-RED icon: mdi:sitemap url: http://127.0.0.1:45180 work_mode: ingress ui_mode: normal # hide HA header on panel page headers: authorization: "Bearer your-nodered-token" # Simple iframe panel (no proxying) external_dashboard: work_mode: iframe title: Dashboard icon: mdi:view-dashboard url: https://grafana.example.com/d/home ``` -------------------------------- ### Docker Compose Configuration for Home Assistant and Addons Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md Defines the services for Home Assistant and Node-RED, including network configuration, volume mounts, and environment variables. The 'dns' service uses Nginx as a DNS proxy, and Home Assistant uses the host network for specific functionalities. ```yaml name: ha networks: default: driver: bridge driver_opts: com.docker.network.bridge.name: hassio ipam: config: - subnet: 172.30.32.0/23 ip_range: 172.30.33.0/24 gateway: 172.30.32.1 services: dns: image: nginx restart: always networks: default: ipv4_address: 172.30.32.3 volumes: - /etc/localtime:/etc/localtime:ro - ./nginx/dns_proxy.conf:/etc/nginx/nginx.conf homeassistant: image: homeassistant/home-assistant restart: always privileged: true network_mode: host dns: - 172.30.32.3 dns_opt: - ndots:0 environment: - TZ=Asia/Shanghai volumes: - /run/dbus:/run/dbus:ro - ./homeassistant:/config - ./share:/share nodered: image: nodered/node-red restart: unless-stopped environment: - TZ=Asia/Shanghai volumes: - ./node-red:/data - ./share:/share # add other services like nodered does ``` -------------------------------- ### Mosquitto Configuration File Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md Configuration for the Mosquitto MQTT broker, including authentication plugin settings and listener configuration. ```python ## # defaults protocol mqtt user mosquitto ## # logging log_dest stdout ## # datastore persistence true persistence_location /etc/mosquitto/ ## # User settings auth_plugin /mosquitto/go-auth.so auth_opt_files_password_path /etc/mosquitto/pw auth_opt_files_acl_path /etc/mosquitto/acl listener 1883 ``` -------------------------------- ### Home Assistant Ingress Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md Enable the ingress integration in your Home Assistant configuration.yaml to allow addons to be accessed through the Home Assistant UI. ```yaml ingress: ``` -------------------------------- ### Zigbee2MQTT Addon Docker Compose Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md Configure the Zigbee2MQTT addon using Docker Compose. This includes mounting the udev device and data volume. ```yaml name: ha services: zigbee2mqtt: image: koenkk/zigbee2mqtt restart: unless-stopped environment: - TZ=Asia/Shanghai volumes: - /run/udev:/run/udev:ro - ./zigbee2mqtt:/app/data devices: - /dev/ttyACM0 ``` -------------------------------- ### Configure Multiple Tabs Interface Source: https://context7.com/lovelylain/hass_ingress/llms.txt Create a custom panel with tabbed navigation using a custom work_mode and JavaScript file. Child panels appear as tabs, preserving iframe state. ```yaml ingress: # Parent tabs panel using custom work_mode tabs: work_mode: custom url: /files/ingress/ha-tabs-ingress.js title: Ingress icon: mdi:cursor-default-click # Child panels appear as tabs ttyd: parent: tabs work_mode: ingress title: Terminal url: http://localhost:7681 nodered: parent: tabs work_mode: hassio # For hassio add-ons title: Node-RED url: a0d7b954_nodered # Add-on slug # Access patterns: # /tabs/_/nodered - tabs mode (iframe preserved) # /tabs/nodered - dashboard mode (single view) ``` -------------------------------- ### Configure Public Terminal and Webhook Access Source: https://context7.com/lovelylain/hass_ingress/llms.txt Set up public access to services like ttyd and Node-RED webhooks via Ingress. Requires a static token for authentication. ```yaml ingress: # Public terminal access without HA login ttyd: work_mode: ingress title: Terminal url: http://localhost:7681 static_token: secret-token-value-for-ttyd # Public webhook endpoint for Node-RED nodered_webhook: parent: nodered work_mode: ingress url: http://127.0.0.1:45180 index: /webhook/ static_token: secret-token-value-for-webhook ``` -------------------------------- ### Configure Parent/Child Panels in YAML Source: https://context7.com/lovelylain/hass_ingress/llms.txt Organize ingress panels hierarchically by defining parent/child relationships in configuration.yaml. Child panels are hidden from the sidebar and accessed via the parent. ```yaml ingress: # Parent panel visible in sidebar nodered: require_admin: true title: Node-RED icon: mdi:sitemap url: http://127.0.0.1:45180 headers: authorization: !secret nodered_auth # Child panel hidden from sidebar, accessible via /nodered/ui 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 ``` -------------------------------- ### Configure Multi-Domain URL Matching for Ingress Source: https://context7.com/lovelylain/hass_ingress/llms.txt Set up different URLs for internal and external network access based on the accessing domain. Uses pattern matching and replacement. ```yaml ingress: openwrt: title: OpenWrt work_mode: auth url: # Match Home Assistant access URL pattern match: (\w+://)hass(\..+) # Replace 'hass' with 'openwrt' in domain replace: $1openwrt$2 # Fallback URL when pattern doesn't match default: https://openwrt.example.com ``` -------------------------------- ### Home Assistant Configuration for Ingress Addons Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md Configures the Ingress integration within Home Assistant to add new addons. This section specifies the require_admin, title, icon, and URL for the Node-RED addon, allowing it to be accessed from the Home Assistant sidebar. ```yaml ingress: nodered: require_admin: true title: Node-RED icon: mdi:sitemap url: nodered:1880 # add other ingress like nodered does ``` -------------------------------- ### Node-RED Addon Docker Compose Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md Configure the Node-RED addon using Docker Compose. Ensure correct ownership of the node-red directory if needed. ```yaml name: ha services: nodered: image: nodered/node-red restart: unless-stopped environment: - TZ=Asia/Shanghai volumes: - ./node-red:/data - ./share:/share ``` -------------------------------- ### Home Assistant Docker Compose Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md Configure the Home Assistant service in your docker-compose.yml. Ensure correct volume mappings for configuration and shared data. ```yaml name: ha services: homeassistant: image: homeassistant/home-assistant restart: always privileged: true network_mode: host dns: - 172.30.32.3 dns_opt: - ndots:0 environment: - TZ=Asia/Shanghai volumes: - /run/dbus:/run/dbus:ro - ./homeassistant:/config - ./share:/share ``` -------------------------------- ### Zigbee2MQTT Addon Ingress Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md Configure Zigbee2MQTT addon access through Home Assistant ingress. Sets a title and icon for the integration. ```yaml ingress: zigbee2mqtt: title: Zigbee2MQTT icon: mdi:zigbee url: zigbee2mqtt:8080 ``` -------------------------------- ### VSCode Addon Ingress Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md Configure VSCode addon access through Home Assistant ingress. Requires admin privileges and sets a specific title and icon. ```yaml ingress: vscode: require_admin: true title: VSCode icon: mdi:microsoft-visual-studio-code url: vscode:8443 ``` -------------------------------- ### OpenWrt Ingress Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md Configure OpenWrt ingress with title, icon, URL, authentication headers, and URL rewriting rules. Use `!secret` for sensitive credentials. ```yaml ingress: openwrt: title: OpenWrt icon: mdi:router-wireless url: 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 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/ ``` -------------------------------- ### Handle Hass Ingress URL with Refresh Source: https://github.com/lovelylain/hass_ingress/blob/main/custom_components/ingress/www/iframe.html This script dynamically sets up an iframe to display an ingress URL. It supports a refresh interval for the iframe content and handles specific API ingress paths. Ensure the 'ingress' URL parameter is correctly provided. ```javascript (() => { const urlParams = new URLSearchParams(window.location.search); let url = urlParams.get("ingress"); if (!url) return; let interval = +urlParams.get("refresh"); document.querySelector("body").innerHTML = ''; const iframe = document.querySelector("iframe"); if (/^\/api\/hassio_ingress\/\^\/\]+\/.test(url)) { if (!(interval >= 5)) interval = 300; iframe.src = url; setInterval(() => { fetch(url, { redirect: "manual" }); }, interval * 1000); } else if (/^\w+(?:$|\/)/.test(url)) { url = `/api/ingress/${url}${url.indexOf("/") === -1 ? "/" : ""}`; iframe.src = url; if (interval >= 5) { setInterval(() => { iframe.src = url; }, interval * 1000); } } iframe.addEventListener("load", () => { document.title = iframe.contentDocument.title; }); })(); ``` -------------------------------- ### VSCode Addon Docker Compose Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md Configure the VSCode addon using Docker Compose. This maps local directories for configuration and data persistence. ```yaml name: ha services: vscode: image: linuxserver/code-server restart: unless-stopped environment: - TZ=Asia/Shanghai - PUID=0 - PGID=0 volumes: - ./vscode:/config - .:/data ``` -------------------------------- ### Ingress Configuration - Multi-Domain URL Matching Source: https://context7.com/lovelylain/hass_ingress/llms.txt Configure different URLs based on the accessing domain for internal and external network access. This allows for seamless access to services regardless of the network the user is connected to. ```APIDOC ## Configuration - Multi-Domain URL Matching Configure different URLs based on the accessing domain for internal/external network access. ```yaml # configuration.yaml ingress: openwrt: title: OpenWrt work_mode: auth url: # Match Home Assistant access URL pattern match: (\w+://)hass(\..+) # Replace 'hass' with 'openwrt' in domain replace: $1openwrt$2 # Fallback URL when pattern doesn't match default: https://openwrt.example.com ``` Access patterns: - From http://hass.local:8123 -> http://openwrt.local - From https://hass.example.com -> https://openwrt.example.com ``` -------------------------------- ### Ingress Configuration - User Info in Headers Source: https://context7.com/lovelylain/hass_ingress/llms.txt Pass authenticated user information to backend services via headers. This feature is available from v1.3.0+ and allows backend services to identify the logged-in Home Assistant user. ```APIDOC ## Configuration - User Info in Headers Pass authenticated user information to backend services via headers (v1.3.0+). ```yaml # configuration.yaml ingress: tandoor_recipes: title: Tandoor Recipes icon: mdi:silverware-fork-knife url: http://tandoor:8080 headers: # $username - HA login username # $user_name - HA display name # $user_id - HA user UUID Remote-User: $username X-User-Display-Name: $user_name X-User-ID: $user_id # Auto-origin header for CORS handling grafana: title: Grafana url: http://grafana:3000 headers: Origin: $auto # Automatically set from forwarded headers ``` ``` -------------------------------- ### Node-RED Addon Ingress Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md Configure Node-RED addon access through Home Assistant ingress. Sets a title, icon, and specifies the URL for access. ```yaml ingress: nodered: require_admin: true title: Node-RED icon: mdi:sitemap url: nodered:1880 ``` -------------------------------- ### Configure Multiple Tabs for Ingress Source: https://github.com/lovelylain/hass_ingress/blob/main/README.md Use this configuration to display web pages in multiple tabs without reloading the iframe when switching tabs. Ensure 'work_mode' is set to 'custom' and 'url' points to the correct JavaScript file. ```yaml ingress: tabs: work_mode: custom # MUST url: /files/ingress/ha-tabs-ingress.js # MUST title: Ingress icon: mdi:cursor-default-click ttyd: parent: tabs work_mode: ingress title: Terminal url: nodered: parent: tabs work_mode: hassio title: Node-RED url: ``` -------------------------------- ### Tandoor Recipes Addon Ingress Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md Configure Tandoor Recipes addon access through Home Assistant ingress. Includes URL, headers, and body rewrite rules for proper path handling. ```yaml ingress: tandoor_recipes: title: Tandoor Recipes icon: mdi:silverware-fork-knife url: tandoor_recipes:8080$http_x_ingress_path headers: Remote-User: admin X-Script-Name: $http_x_ingress_path Origin: $auto rewrite: - mode: body path: /api/ingress/\w+/\w+/$ match: (href=".*/api/ingress/\w+)" replace: \1/" tandoor_recipes_static: parent: tandoor_recipes work_mode: subapp url: tandoor_recipes:8080/api/ingress/tandoor_recipes$http_x_ingress_path rewrite: - mode: body path: /api/ingress/.*/static/themes/tandoor\.min\.css$ match: (url\()/(static)/ replace: \1$http_x_ingress_path/\2/ ``` -------------------------------- ### Tandoor Recipes Addon Docker Compose Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md Configure the Tandoor Recipes addon using Docker Compose. Sets environment variables for authentication and script paths. ```yaml name: ha services: tandoor_recipes: image: vabene1111/recipes restart: unless-stopped environment: - TZ=Asia/Shanghai - REMOTE_USER_AUTH=1 - SCRIPT_NAME=/api/ingress/tandoor_recipes - JS_REVERSE_SCRIPT_PREFIX=/api/ingress/tandoor_recipes - STATIC_URL=/api/ingress/tandoor_recipes_static/static/ - MEDIA_URL=/api/ingress/tandoor_recipes_static/media/ ``` -------------------------------- ### Service - Reload Configuration Source: https://context7.com/lovelylain/hass_ingress/llms.txt Reload ingress configuration without restarting Home Assistant using the `ingress.reload` service. This is useful for applying changes to ingress configurations dynamically. ```APIDOC ## Service - Reload Configuration Reload ingress configuration without restarting Home Assistant via the reload service. ```yaml # Reload via Developer Tools UI: # Navigate to Developer Tools > Services # Click "INGRESS" button to reload configuration # Reload via service call service: ingress.reload ``` ``` -------------------------------- ### Pass User Info to Backend Services via Headers Source: https://context7.com/lovelylain/hass_ingress/llms.txt Configure Ingress to pass authenticated user information to backend services using headers. Supports HA login username, display name, and user ID. Requires v1.3.0+. ```yaml ingress: tandoor_recipes: title: Tandoor Recipes icon: mdi:silverware-fork-knife url: http://tandoor:8080 headers: # $username - HA login username # $user_name - HA display name # $user_id - HA user UUID Remote-User: $username X-User-Display-Name: $user_name X-User-ID: $user_id # Auto-origin header for CORS handling grafana: title: Grafana url: http://grafana:3000 headers: Origin: $auto # Automatically set from forwarded headers ``` -------------------------------- ### Reload Ingress via REST API Source: https://context7.com/lovelylain/hass_ingress/llms.txt Use this curl command to trigger a reload of the ingress services via the Home Assistant REST API. Ensure you replace YOUR_LONG_LIVED_TOKEN with your actual token. ```bash curl -X POST \ -H "Authorization: Bearer YOUR_LONG_LIVED_TOKEN" \ -H "Content-Type: application/json" \ "http://localhost:8123/api/services/ingress/reload" ``` -------------------------------- ### Configure URL Rewriting for Absolute Paths Source: https://context7.com/lovelylain/hass_ingress/llms.txt Use rewrite rules in configuration.yaml to fix absolute URLs in backend service responses, ensuring compatibility with ingress proxying. Supports body and header rewriting. ```yaml ingress: openwrt: title: OpenWrt icon: mdi:router-wireless-settings url: http://192.168.0.1/ headers: # Auto-login credentials passed to backend http-auth-user: !secret openwrt_user http-auth-pass: !secret openwrt_auth rewrite: # Rewrite absolute URLs in HTML response body - mode: body match: /(luci-static|cgi-bin)/ replace: $http_x_ingress_path/\1/ # Rewrite escaped paths in JavaScript - mode: body match: \/(luci-static|cgi-bin|ubus)\ replace: $http_x_ingress_path/\1/ # Rewrite Location and Set-Cookie headers - mode: header name: "(Location|Set-Cookie)" match: /cgi-bin/ replace: $http_x_ingress_path/cgi-bin/ ``` -------------------------------- ### Listen for Reload Completion Event Source: https://context7.com/lovelylain/hass_ingress/llms.txt This is an event type that Home Assistant emits when the ingress services have been reloaded. You can listen for this event to trigger subsequent actions. ```yaml # Event type: event_ingress_reloaded ``` -------------------------------- ### Rewrite Rule Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/README.md Defines rules for rewriting response bodies or headers. Supports specifying the mode (body/header), path, header name, match pattern, and replacement. ```yaml rewrite: - mode: body path: /.* match: RegEx pattern to search in body or header value. replace: Python Replacement for the matched RegEx, use \1, \2 to reference capture groups. $http_x_ingress_path in this option will be replaced with /api/ingress/{name}. ``` -------------------------------- ### Access Ingress Proxy Endpoints via API Source: https://context7.com/lovelylain/hass_ingress/llms.txt Interact with proxied services through the Ingress API. Supports direct access, static token access, and nginx auth_request endpoints. Includes response code information. ```bash # Access ingress panel (redirects to set cookie then proxies) curl -L "http://localhost:8123/api/ingress/{panel_name}/" # Access with static token (no authentication required) curl "http://localhost:8123/api/ingress/t-{static_token}/" # Auth mode endpoint for nginx auth_request # Headers required: X-Ingress-Name, X-Original-URL # Optional: X-Hass-Origin curl -H "X-Ingress-Name: openwrt" \ -H "X-Original-URL: https://openwrt.example.com/cgi-bin/luci" \ -H "X-Hass-Origin: https://hass.example.com" \ "http://localhost:8123/api/ingress/_/auth" # Response codes: # 200 - Valid token, headers contain backend auth headers # 401 - Invalid/missing token, Location header has login redirect # 404 - Ingress name not found # Pass URL parameters to override index curl "http://localhost:8123/{panel_name}?index=/custom/path" ``` -------------------------------- ### Ingress Configuration - Public Access Source: https://context7.com/lovelylain/hass_ingress/llms.txt Configure ingress services for public terminal access and webhook endpoints. These services can be accessed directly via generated URLs without requiring a Home Assistant login. ```APIDOC ## Configuration - Public Access Configure ingress services for public terminal access and webhook endpoints. These services can be accessed directly via generated URLs without requiring a Home Assistant login. ```yaml # configuration.yaml ingress: # Public terminal access without HA login ttyd: work_mode: ingress title: Terminal url: http://localhost:7681 static_token: secret-token-value-for-ttyd # Public webhook endpoint for Node-RED nodered_webhook: parent: nodered work_mode: ingress url: http://127.0.0.1:45180 index: /webhook/ static_token: secret-token-value-for-webhook ``` Access URLs (no authentication required): - `/api/ingress/t-secret-token-value-for-ttyd/` - `/api/ingress/t-secret-token-value-for-webhook/` ``` -------------------------------- ### Auth Request Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/README.md Configure auth_request for backend services not proxied by ingress. Specifies API endpoint, request headers, and response headers for authentication. ```ini auth_request api: /api/ingress/_/auth request header: X-Ingress-Name(ingress_name), X-Original-URL($scheme://$http_host$request_uri), X-Hass-Origin(hass_url) response header: Set-Cookie(ingress_token) if succ, Location(login_url_path) if 401. ``` -------------------------------- ### Docker Compose DNS Proxy Service Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md Configures the Nginx service to act as a DNS proxy. It listens on UDP port 53 and forwards requests to a specified upstream address, essential for resolving addon hostnames within the Docker network. ```yaml name: ha services: dns: image: nginx restart: always networks: default: ipv4_address: 172.30.32.3 volumes: - /etc/localtime:/etc/localtime:ro - ./nginx/dns_proxy.conf:/etc/nginx/nginx.conf ``` -------------------------------- ### Reload Ingress Configuration via Service Call Source: https://context7.com/lovelylain/hass_ingress/llms.txt Reload the Ingress configuration without restarting Home Assistant. This can be done via the Developer Tools UI or a service call. ```yaml # Reload via Developer Tools UI: # Navigate to Developer Tools > Services # Click "INGRESS" button to reload configuration # Reload via service call service: ingress.reload ``` -------------------------------- ### WebSocket API - Session Management Source: https://context7.com/lovelylain/hass_ingress/llms.txt Generate and validate user session tokens via WebSocket for frontend integration. These tokens are used to authenticate user sessions for ingress services. ```APIDOC ## WebSocket API - Session Management Generate and validate user session tokens via WebSocket for frontend integration. ```javascript // Generate session token (requires authenticated WebSocket) const connection = await createConnection({ auth }); const result = await connection.sendMessagePromise({ type: "ha-ingress/session" }); console.log(result.session); // Base64 token string // Validate existing session token const validation = await connection.sendMessagePromise({ type: "ha-ingress/validate_session", session: "existing-token-value" }); console.log(validation.user_id); // User UUID if valid // Token is stored as cookie: ha_ingress_session // Token validity: 300 seconds (auto-refreshed on use) ``` ``` -------------------------------- ### API - Ingress Proxy Endpoints Source: https://context7.com/lovelylain/hass_ingress/llms.txt Access proxied services through the ingress API with automatic token handling. This allows direct access to services via specific URLs or through authentication proxies. ```APIDOC ## API - Ingress Proxy Endpoints Access proxied services through the ingress API with automatic token handling. ```bash # Access ingress panel (redirects to set cookie then proxies) curl -L "http://localhost:8123/api/ingress/{panel_name}/" # Access with static token (no authentication required) curl "http://localhost:8123/api/ingress/t-{static_token}/" # Auth mode endpoint for nginx auth_request # Headers required: X-Ingress-Name, X-Original-URL # Optional: X-Hass-Origin curl -H "X-Ingress-Name: openwrt" \ -H "X-Original-URL: https://openwrt.example.com/cgi-bin/luci" \ -H "X-Hass-Origin: https://hass.example.com" \ "http://localhost:8123/api/ingress/_/auth" # Response codes: # 200 - Valid token, headers contain backend auth headers # 401 - Invalid/missing token, Location header has login redirect # 404 - Ingress name not found # Pass URL parameters to override index curl "http://localhost:8123/{panel_name}?index=/custom/path" ``` ``` -------------------------------- ### Nginx DNS Proxy Stream Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md This Nginx configuration sets up a stream server to listen on UDP port 53 for DNS requests and proxy them to a local DNS resolver (127.0.0.11:53). This is used to provide DNS resolution for containers within the custom Docker network. ```c++ user nginx; worker_processes 1; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } stream { log_format main '$remote_addr [$time_local] "$upstream_addr" $protocol ' '$status $bytes_sent $bytes_received $session_time'; server { access_log /var/log/nginx/access.log main; listen 53 udp; proxy_pass 127.0.0.11:53; proxy_timeout 10s; } } ``` -------------------------------- ### Docker Compose Network Configuration Source: https://github.com/lovelylain/hass_ingress/blob/main/addons-for-docker-installation.md Defines a custom bridge network named 'hassio' for Docker containers. This network uses a specific subnet, IP range, and gateway, allowing containers to communicate with each other and with Home Assistant. ```yaml name: ha networks: default: driver: bridge driver_opts: com.docker.network.bridge.name: hassio ipam: config: - subnet: 172.30.32.0/23 ip_range: 172.30.33.0/24 gateway: 172.30.32.1 ``` -------------------------------- ### Generate and Validate User Session Tokens via WebSocket Source: https://context7.com/lovelylain/hass_ingress/llms.txt Use the WebSocket API to generate and validate user session tokens for frontend integration. Tokens are stored as cookies and auto-refreshed. ```javascript // Generate session token (requires authenticated WebSocket) const connection = await createConnection({ auth }); const result = await connection.sendMessagePromise({ type: "ha-ingress/session" }); console.log(result.session); // Base64 token string // Validate existing session token const validation = await connection.sendMessagePromise({ type: "ha-ingress/validate_session", session: "existing-token-value" }); console.log(validation.user_id); // User UUID if valid // Token is stored as cookie: ha_ingress_session // Token validity: 300 seconds (auto-refreshed on use) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.