I have followed this tutorial to enable access to my Home Assistant project using SSH connection and it works like a charm.
Now, I would like to do the same with the Traefik tool without Nginx. But I get an 502 - Bad Gateway error and the Home Assistant Add-on Autossh can't established the connection.
To do that, I have used this tutorial with this configuration :
You only have a service defined. You also need a router. As you're getting a 502 I suppose you have defined this but not shared it.
The example in the tutorial does not use localhost, for a good reason. Each container has it's own network namespace so localhost is the traefik container itself, not the docker host. So you need to use an ip address of the host.
This assumes that HomeAssistant is running native on the machine, not as a container.
Ok, I understand but I only need to connect to the Traefik host machine. So with the ip address of the host machine (http://192.168.1.59:44400) this has to work ? (I tried it but get an Gateway Timeout).
I don’t understand your question, sorry.
The raspberry where is hosted Traefik have the 80 and 443 ports open.
And the home assistant is on an another raspberry, not in the same local network.
Ok cool !
Yes, the raspberry where the traefik is running has the 80 and 443 opened ports on my internet box.
And I have configured a dyndns domain name to access the externally.
I don't know if I correctly answer to your question ?!
I'm looking for a solution with Traefik to do my own Ngrok alternative. I have multiple a home assistant with the Autossh plugin installed on an another server and would like to access to it by entered the url : home-assistant.server.com
Authssh is configured with the remote forwarding port : 44400:localhost:8123, on ssh port (22).
I found this Traefik configuration (Traefik V1) but would like to use Traefik V2. I obtain a Bad gateway with my new Traefik configuration.
My main objective is to connect multiple rapberrypi with home assistant.
Maybe this solution is not the best to do it and you could suggest me some alternatives.
Localhost is the traefik container itself. Each container has it's own network namespace. This need to be either the ip of the docker host, or the ip of the docker network gateway()usually the x.x.x.1 of the docker network.
SSH is typically TCP and is does not use TLS as a transport protocol. So you likely want to be using a tcp router with rule HostSNI(`*`) .
The existing router you have is sufficient for the https access once you update the service url to a correct ip address.
Ok, thanks !
So, I found the ip of the docker host (172.17.0.1).
So, I don't understand very well why have I to use a TCP router.
To resume, I have a http connection from my browser on url : https://home-assistant.server.com
Then, this request is routing to the 44400 port through SSH.
So, I have tried this configuration, but an "Error while connection to backend: dial tcp 172.17.0.1:44400: connect: connection refused".
So something is rejecting the connection or the port is not bound/available in that ip.
If you are using a standard ssh forwarding that will only bind to 127.0.0.1, so you may have to change that.
Here is the difference between:
-L 3000:localhost:3000
ss -tnl 'sport = :3000'
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 127.0.0.1:3000 0.0.0.0:*
-gL 3000:localhost:3000
ss -tnl 'sport = :3000'
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:3000 0.0.0.0:*
-L 0.0.0.0:3000:localhost:3000
ss -tnlp 'sport = :3000'
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:3000 0.0.0.0:*
It works if I update the allowTcpForwarding yes.
But this is not the ideal and inside Home Assistant, the cameras and other http services are not displaying.
In more, inside a new anonymous browser tab, I can't request the interface...
Very strange cause with the nginx configuration, all is working !