Hassio as a web server / addon

Hi, you may have a look here.
The AddOn tutorial includes setting up a python3 http server.

EDIT: Link updated

Thanks, I’ll dig into it!

Old topic I know, but a generic web server add-on would be really useful (I’ve looked and not found one). I’ve got some simple php pages that I’d like to use for my weather station.

@frenck could you add one to your repertoire, please? :pleading_face:

1 Like

The problem is “what is generic?” You use PHP as a server side language. Some people use other languages. As a developer of such an add-on it would mean all kinds of people asking to add support for whatever language or Apache module or anything like that to add to the HA add-on. I don’t think this would be a good way to spend HA development time. If you install HA on your RPI on top of a normal raspbian image using docker (explained on the installation page in the documentation on the HA website) you can choose from the many LAMP docker containers on docker hub to run on the side.

Yes I acknowledge that. I’m sure there are solutions to that though. For me, it would certainly not be for anything that required a complex setup - it is for the hosting of a simple mini website. I also suspect that, for someone who knows the add-on system, it would be relatively quick as it seems that various parts are already templated. I would also wager that PHP modules could easily be included (much like Node-RED npm packages can be installed via the options).

My thought is that there are lots of custom views that could then be created using the iframe card in Lovelace that could point to this local webserver.

The problem with a generic docker, is it loses the integration with the supervisor, SSL etc.

3 Likes

If anyone is still searching for this. I have created a apache2 hassio addon.
More information is here: https://github.com/FaserF/hassio-addons/tree/master/apache2

8 Likes

I’ve installed the add-ons for DuckDNS, MariaDB, phpMyAdmin and your Apache2. My index.html displays just fine. Thank you very much! However, none of my .php programs will display. Perhaps you can tell me the most likely cause of php problems. I’m not sure where to start.

Have you tried it with my newest version? I have fixed some bugs.
Does no php page work or only some?

Thanks FaserF !! What whould be the way if I want to host more thant 1 web site. NGINX reverse proxy doesnt allow me to redirect to subpath, only other port.

Hey, when I try to install your add on (the full version) it is failing. Does this mean anything to you?

The command ‘/bin/ash -o pipefail -c apk add --no-cache $MUSL_LOCALE_DEPS && wget https://gitlab.com/rilian-la-te/musl-locales/-/archive/master/musl-locales-master.zip && unzip musl-locales-master.zip && cd musl-locales-master && cmake -DLOCALE_PROFILE=OFF -D CMAKE_INSTALL_PREFIX:PATH=/usr . && make && make install && cd … && rm -r musl-locales-master’ returned a non-zero code: 99

I have reproduced your issue and fixed it in the newest version 2.1.0
Please give it a new try with that version.

Btw on what hardware where you running the addon?

hmmm, good question. Right now I dont have support in my addons for multiple sites.
You could use for example the full apache2 addon and also a minimal apache2 addon from my addons.
Both at the same time. This would allow you to host multiple sites.

Hey - it’s working now, I was able to install the addon.

I do have another question, and it is probably extremely stupid, but… I’m not quite sure how to access the page I created.

I created it a while back and was hosting it (locally) with Xampp, so I just copied my htdocs folder to my Home Assistant PI (Pi\share\htdocs).

But when I launch the web UI from the addon I just get: 502: Bad Gateway

I’ve not configured SSL so basically the only thing of note in my configuration is the document_root: /share/htdocs

I feel extremely stupid. :slight_smile:

There is no need to feel stupid :slight_smile:
If you are launching the web ui from the addon (ingress) it is normal to get the 502 error.
That is due to the need of an SSL certificate, described here:

and here: Apache | Open Web UI results in 502: Bad Gateway · Issue #5 · FaserF/hassio-addons · GitHub

So you have to ways:

  • Open your website through your browser: http://ipfromyourpi:portdefinedinthehaaddon
  • Install my OpenSSL Addon and use a OpenSSL certificate, setup the certificate in the addon config → Then you should be able to use ingress

Doh! That makes sense now. I had been playing around with it that way too and was getting a connection error, now I realise it was actually a connection error generated from my php failing to connect to the DB. I remembered that when I installed through XAMPP it went through the process of creating the underlying DB etc too.

Now I’ll try figure that out - thanks again for your help.

When it says Open Web UI this does not mean a web UI for Apache2, it means your actual page?

Exactly, it will open your website, that you have defined in the addon settings which is just hosted by the apache2 addon.

okay, okay, great! thank you! basically the key to getting everything to wokr is understanding nginx whcih i messed with all day today. I was thinking Open WebUI was supposed to open some kind of special admin page for apache or whatever.

Thank you!!

Hey man, I thought of something else I Wanted to ask you. Is there really no way to like run multiple instances of the add-on through 1 HA OS install? I’d really like to try and host another page becauze neither of them are going to get alot of traffic. Have you ever see nanyone host 2 pages with your add-on?

Thanks

If you want to host multiple Apache2 Servers, you could install my other Apache2 addon:

I am distributing three variants. Maybe another variant already suits you needs.

Or you could download my apache2 addon, and then install it as a local addon, so you could host multiple instances of my addon (but you wont recieve auto updates etc for local addons).

I am just thinking of distributing another dummy addon, which would just be copy, but would need maintainance too.

1 Like