HassIO and traefik

I’m running HassIO together with several other containers on Intel NUC running Debian.
I use Traefik as a reverse proxy for my docker containers so I can access them remotely over internet and I would like to do the same with HassIO and traefik.

The problem is that I don’t know how to set it up. With the normal containers I just add a few lines after each container in my docker-compose file but that is of course not possible for HassIO.

Is there anyone who have and idea of how to do it or have solved it?

I dont use Traefik, but based on this guide


why cant you just create a conf file for hass.io and that’s it.

The .conf file part is for a nginx proxy, but I got another idea from that article Which I\m going to try.

Unfortantly HassIO decided to suddenly crash and now it is not starting so I have to fix that first.
Maybe I just go over regular docker HA…

I have another suggestion.
hass.io has a caddy add on.
you can use this to expose all the apps you want.
apparently it’s very easy to use and there’s examples in the forum

Yeah I looked at the Caddy addon but I use cloudflare for my dns provider and it seems that you need an plug-in to caddy to be able to use cloudflare. That that addon is not installed with the hassio caddy-addon.
And I really like how simple traefik is to use and manage for me.

Fortunatly I managed to find a solution:
By adding this to my traefik.toml file
[file]

[backends]
  [backends.hassio.servers.server1]
    url = "http://internal.hass.ip:8123"
	
[frontends]
  [frontends.hassio]
  backend = "hassio"
    [frontends.hassio.routes.hassio_1]
    rule = "Host:hassio.domain.name"

I hope this helps someone else looking to use traefik with HassIO.

5 Likes

Hi there,

I made an add-on that embed Traefik on HassIO.
It’s working on my setup, but it should be still considered as “work in progress”.

If you want to have a look on it : https://github.com/MrRaph/hassio-addons/tree/master/traefik-proxy

Cheers !

2 Likes

Do you use Google Assistant/Home with HASS, is it working fine?

Hey I am new to traefik and stumbled upon this post. I tried adding this snippet to my traefik.toml file but it does not seem to be working right. The only things I changed from your example were my private IP and update the rule to point to my domain.

These questions come to mind:

  1. As I’m new to Traefik, does the “backend =“ line need to be the name of my docker container. My container name is homeassistant (it’s actually hass.io though, the docker_supervisor container gets spun up along side it).

  2. Do any of the other references to hass.io in your code need to be changed as well?

  3. Do I need to specify the name of the proxy network I created in my docker run command as well? I actually used a script to deploy hass.io so I’ll have to piece together what the docker run command should be if so.

Sorry to bombard you with all the questions but I’d really like to get this working.

Thanks in advance.

I’m far from a expert on Traefik but I’m going to try my best to give you an anwser.

  1. The “backend=” line doesn’t need to be the same as the docker container. It can be whatever you want, as long as “backend=XX” is the same as “[backends.XX.servers.server1]”. Thats how you tell traefik what frontend and backend are connected.

  2. Nope. That code snippet is basicly the only thing I have which connects Hassio with traefik.

  3. You shouldnt need that. Normally when you use traefik in a docker-compose file you have to make sure traefik is on the same docker network as the other containers. But I couldn’t do that (or at least I didn’t know how) because I also used the official Intel NUC script for Hassio. So I directed the traefik traffic directly to the computer host ip, including the Hass port, with the “[file]” method above.

I don’t know if this helps but I’m using the wildcards DNS method with Cloudflare. I basicly used this guide for my docker and traefik setup with the snippet from above to make it work with HassIO instead of using regular home assistant docker.

I could paste my hole trafik.toml this evening if you think it would help.