lovelylain / hass_ingress

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

Ingress tabs Looping back to main HA instance #3

Closed hijamie32 closed 2 months ago

hijamie32 commented 3 months ago

Hi,

Many thanks for the work on the integration.

I am having a strange issue. Node red that is running in a separate container works fine.

However anything else I try (other separate containers running on NAS or even router ip) either don't load and are blank, or loop back and show another copy of the main HA instance on the dashboard (window in window). This happens even with completely separate and non related ip's / ports.

I am using NPM for remote access but this happens with the addon enabled and disabled so don't think it is related.

Any idea I would be very grateful.

Many thanks.

Jamie

Screenshot 2024-03-11 at 18 58 15 Screenshot 2024-03-11 at 18 58 01
lovelylain commented 3 months ago

Show me your configuration pls.

hijamie32 commented 3 months ago

Thanks here you go:

The top two work fine local and remote, however the bottom two for both local and remote - ngix is blank & the router page just loops back to home assistant.

This is all fairly new to me so apologies if it is a simple error on my part!

Cheers for your help

ingress: mdiindex: ingress: false title: MDI Index icon: mdi:vector-square url: https://pictogrammers.com/library/mdi/category/home-automation/ toolbar: true nodered: require_admin: false title: Node-RED icon: mdi:sitemap toolbar: true url: http://192.168.1.190:1880
ngix: require_admin: false title: NGIX icon: mdi:home-assistant toolbar: true url: http://192.168.1.42:81 router: require_admin: false title: Router icon: mdi:sitemap toolbar: true url: http://192.168.1.190:8080 index: /cgi-bin/

lovelylain commented 3 months ago

ngix: is it ok to access http://192.168.1.42:81/ directly in the browser? router: is it an openwrt? openwrt will reply a redirect if not login, you can use nginx's sub_filter fix it, https://github.com/lovelylain/hass_ingress/issues/1#issuecomment-1983617932

hijamie32 commented 3 months ago

Hi, Yes direct in browser works fine for both.

Router is not openwrt, trying to ingress into a another instance of HA also just links back to the main instance even though they again are different IP's and ports, so don't think it is a router issue:

title: HA icon: mdi:home-assistant toolbar: true url: http://192.168.1.190:668

My main instance is 192.168.1.42:8123

Thanks again

lovelylain commented 3 months ago

ngix: you can view network log in browser F12 mode. router: 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 to use nginx's sub_filter to fix the absolute paths in the response.

hijamie32 commented 3 months ago

Would that be applicable to the remote HA instance as well?

Can't work out why it is just redirecting me back to the main HA instance....

lovelylain commented 3 months ago

A URL contains several parts: domain name, port, and path. The domain name and port of HA are shared when the ingress proxy is used, so different services must be identified through paths. Hass ingress will assign a path prefix to each service. If the service only uses relative paths There will be no problem, if it uses the absolute path / it will access the HA resources. Your router behaves the same as openwrt and will redirect to /. You can deploy nginx in front of HA to correct the link. Of course, this is not easy to configure, so you can also choose to set ingress:false. At this time, it performs basically the same as the iframe panel, but has richer functions. You can hide it from the sidebar or add any HA page to the sidebar.

lovelylain commented 2 months ago

For unsupported backend services, you can try work_mode: auth to work with another domain reverse proxied by nginx, or use nginx's sub_filter to fix the absolute paths in the response.