Skip to content

Added Hass.io Ingress support - #63

Closed
ammmze wants to merge 2 commits into
hassio-addons:masterfrom
ammmze:master
Closed

Added Hass.io Ingress support#63
ammmze wants to merge 2 commits into
hassio-addons:masterfrom
ammmze:master

Conversation

@ammmze

@ammmze ammmze commented Dec 18, 2019

Copy link
Copy Markdown

Proposed Changes

Added Hass.io Ingress support

Related Issues

#44, #47, #59, #62

@addons-assistant

Copy link
Copy Markdown

💖 Thanks for opening this pull request! 💖 If your PR gets accepted and merged in, we will invite you to the project 🎉

location /data/firmwares {
}

location ^~ /data/ {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I added ^~ to this line so that it actually matched. In the current master version I found I was able to access /data/MyConfig.json which exposes your credentials.

Comment thread tasmoadmin/config.json
Comment thread tasmoadmin/Dockerfile
\
&& apk add --no-cache --virtual .build-dependencies \
git=2.22.0-r0 \
git=2.22.2-r0 \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be in this PR.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docker image failed to build without it...so 🤷‍♂

Comment thread tasmoadmin/config.json
"hassio_api": true,
"hassio_role": "default",
"ingress": true,
"ingress_port": 8099,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why the port is hardcoded for this add-on?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reasoning behind it is that the port is hard coded in the nginx ingress, so should hass.io ever change it's default port, it wouldn't matter as we have explicitly defined it here.

Comment thread tasmoadmin/config.json
],
"ports": {
"9541/tcp": 9541
"9541/tcp": null

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like a bad idea. How do the firmware updates get across?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, I haven't used the firmware update process. Initially I figured it would go through the ingress, but I guess that wouldn't work since it would need to be authenticated.

Comment thread tasmoadmin/config.json
"certfile": "fullchain.pem",
"keyfile": "privkey.pem"
},
"panel_icon": "mdi:network",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this fit?

# ==============================================================================


# The general idea is that the nginx server will be configured to have a root of

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like comments in code, but this extreme.

declare ingress_dir="${ingress_root_dir}${ingress_entry}"

# Create nginx server
sed "s#%%ingress_entry%%#${ingress_entry}#g" \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the standard as we do in the community add-ons. I like to keep method the same across all add-ons to be able to maintain things.

awk '1;/public function read\(/{ print "if ($key == \"login\" && @$_SERVER[\"ASSUMED_AUTH\"] == \"1\") return \"0\";"}' \
"${app_root_dir}/includes/Config.php" > "${app_root_dir}/includes/IngressConfig.php"

cat << EOF > "${app_root_dir}/includes/IngressInit.php"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reason to do this in Bash.


sed -i "s#%%certfile%%#${certfile}#g" /etc/nginx/nginx.conf
sed -i "s#%%keyfile%%#${keyfile}#g" /etc/nginx/nginx.conf
sed "s#%%certfile%%#${certfile}#g ; s#%%keyfile%%#${keyfile}#g" /etc/nginx/servers/direct-ssl.disabled > /etc/nginx/servers/direct-ssl.conf

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't combine replacements in a single call.

@@ -0,0 +1,47 @@
#!/usr/bin/with-contenv bashio

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ingress is not an application. Please split across the nginx.sh and tasmoadmin.sh

rewrite ^/([a-zA-Z_]+)/?$ /index.php?page=$1;
}
}
include /etc/nginx/servers/*.conf;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the Nginx config structure as used by other community add-ons as well.
Which is not this. Keeping things similar makes maintenance easier.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frenck

frenck commented Dec 18, 2019

Copy link
Copy Markdown
Member

Thanks for your work, but this is made from a single add-on perspective (instead of the similarity between all the add-on in this repository).

One of the main reasons to use TasmoAdmin is to manage your Tasmota devices across your network centrally, including firmware upgrades. This makes this add-on unsuitable for Ingress from a general standpoint.

I'm really not keen on supporting Ingress in this application.
Therefore, I'm going to close this PR. Thanks for you contribution though! 👍

@frenck frenck closed this Dec 18, 2019
@ghost

ghost commented Dec 18, 2019

Copy link
Copy Markdown

If you not support ingress for me it is not addon for Home Assistant. It is as other external software. If it is addon to Hassio i think that should supoort ingress. It is my opinion. We need central managment for all and if we install in Hassio we want have access from Hassio GUI. Look many people need this in GUI as side bar - Ingrees

@ammmze

ammmze commented Dec 19, 2019

Copy link
Copy Markdown
Author

I completely agree! Honestly the only rub I see is that without also exposing the container port then you can't do firmware upgrades of your devices. But I imagine an enhancement to the hass.io ingress could be made to allow an addon to whitelist some anonymous paths which would then allow our devices access to the firmware files and avoid the need to expose the port. But until that happens, I think opening the port is a fine workaround but we'd still get the benefit of easy access to the tasmoadmin web ui to manage the device settings.

@frenck

frenck commented Dec 19, 2019

Copy link
Copy Markdown
Member

If you not support ingress for me it is not addon for Home Assistant.

That is nice, but not all add-ons are capable or sane to use Ingress on. Ingress is a feature, not a requirement. For example, some add-ons require non-TCP ports, others serve things that are not "inside" Home Assistant or the application itself is simply not able to handle dynamic subfolders in requests paths.

We need central managment for all and if we install in Hassio we want have access from Hassio GUI

Home Assistant has offered a iframe_panel for that for ages already.

Honestly the only rub I see is that without also exposing the container port then you can't do firmware upgrades of your devices

Which is one of the main goals of this project! Centrally managing your Tasmota Devices. For control, we use Home Assistant, right?

But I imagine an enhancement to the hass.io ingress could be made to allow an addon to whitelist some anonymous

That is not how Ingress works.

@ammmze

ammmze commented Dec 19, 2019

Copy link
Copy Markdown
Author

Home Assistant has offered a iframe_panel for that for ages already.

But that requires that I expose that port externally just to manage the devices from the UI. The purpose of the ingress is to allow access to the web applications without having to expose a given port.

frenck commented Dec 19, 2019

Copy link
Copy Markdown
Member

But that requires that I expose that port externally just to manage the devices from the UI.

Only if you actually want to upgrade/configure devices when you are externally yourself, other cases that seems not needed.

@ammmze

ammmze commented Dec 20, 2019

Copy link
Copy Markdown
Author

Okay...I appreciate the little bit of direction in the review, i've made many updates...feel free to continue to close the Issues that I'm sure will continue to roll in ;)

If anyone wants a version of the TasmoAdmin addon with Ingress support, i've setup a hass.io repository you can add: https://github.com/MashupMill/hassio-addons

@frenck

frenck commented Dec 20, 2019

Copy link
Copy Markdown
Member

@ammmze In all fairness and friendliness, that is really short-sighted to say like that. Some users want A others want B, there is no possible way to please everyone. For example, Grafana added Ingress, and I'm still closing issues that continue to roll in asking to remove it.

So it is not black or white, it is a choice that I made carefully. I'm fine with somebody not to agree on that. That is what forks are for 👍

@ammmze

ammmze commented Dec 20, 2019

Copy link
Copy Markdown
Author

Not trying to be insulting or anything. Though to be honest it seems like it would be relatively easy to have a configuration option to enable/disable the ingress which gives the user the ability to choose. After all, Home Assistant was designed to give the user the ability to customize, why should the hass.io add-ons be any different.

@frenck

frenck commented Dec 20, 2019

Copy link
Copy Markdown
Member

Hass.io cannot disable Ingress, it is statically enabled in the add-on configuration.

@ammmze

ammmze commented Dec 20, 2019

Copy link
Copy Markdown
Author

Sounds like an opportunity for improvement! If nothing else disable the ingress server in nginx though maybe hass.io may consider it as not having come up...idk. My point is that we're not at the end of the road. Things can (and should) change and be enhanced over time.

@addons-assistant

Copy link
Copy Markdown

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@addons-assistant addons-assistant Bot locked as resolved and limited conversation to collaborators Jan 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants