I hear a lot of good things from Caddy, that being said, I see very little here or on the web on how to install on a Raspberry Pi.
I assume that with this setup, I could still use Alexa and other cloud hosed devices such as Automatic and Eight Sleep … correct?
If so, I wonder if someone could spend time for a detailed writeup on how to succesfully install Caddy for use with Home assistant.
Install instructions for folks using AIO, what user to install it under (pi or homeassistant) I would also prefer to use DynDNS isntead of duckdns. Finally what port to open up on the router not only to access from the outside, but also to assist with cert renewal.
I am finally at a point that my setup is working well and would hate to mess it up by me hacking around. Lastly, if someone could chime in on how secure this is, I would mostly be concerned about someone getting to my secret.yaml file to get user accounts and passwords. Thanks
@hijinx Thanks for your reply. Yes, I did use that thread as a guide to assist along with steps from this script https://gist.github.com/Jamesits/2a1e2677ddba31fae62d022ef8aa54dc which was pretty useful. I think that I am on the home stretch, but still couldn’t make the connection last night. I am still not 100% sure that my certificates are readable by Home Assistant, not sure how I can validate. Also not 100% sure how my port forwarding should be setup. This (below) is the post that I have at the bottom of the thread that you pointed. Any comments would be appreciated.
In your configuration.yaml file, did you use base URL?
Ex.: base_url: your.site.org:8123
Also does your cert setup look like this?
ssl_key: /etc/ssl/caddy/acme/acme-v01.api.letsencrypt.org/sites/your.site.org/your.site.org.key
Lastly for port forwarding do you forward 80 --> 80 and 443 --> 8123?
HA does not have to read the certs. Caddy “wraps” the HTTP with HTTPS (SSL/TLS).
As far as HA is concerned it is not using SSL/TLS.
Ports should be 80–>80 and 433–>433 only. Both are required for letsencrypt to interact with the proxy and provide the certificates.
The reverse proxy will be responsible to map HA port 8123 to a subdomain of your domain.
I use docker so caddy is running in a container.
This means that Caddyfile and cert locations are flexible because they are mapped into the container.
I am using the caddy image from here: Docker
You need to update your DNS so that there is an A record for homeassistant.mydomain.com pointing to your IP
This may not be a problem if you’re using a dynamic DNS provide such as the ever popular duckdns…
Your router must support DNS hairpinning to be able to access the external URL internally
@hijinx Thanks for your help, I made great strides, I think that it was an issue with formatting of my Caddyfile.
I am almost there … as a matter of fact, I had it working for a short time and was able to access the site from my phone (since I don’t think that my router is capable of NAT hairpin). But the issue was that it let me in straight through without a password. So I cam home and remove the “trusted_networks:” entry from my configuration.yaml, then I started getting 403: Forbidden error messages. even when I reversed the changes, I am still getting a 403: Forbidden error. So now I have to troubleshoot this some more.
Found my issue for the 403: Forbidden error and wanted to document it here in case someone else runs into the same issue.
For some reason, the IP address of my Raspberry Pi (the box that houses Home Assistant) listed itself in the ip_bans.yaml file. So the server was blocking itself. Removing the entry from this file fixed the issue.
I use duckdns as dynamic dns provider, so I put it in homeassistant property. I have my duckdns domain CNAME’d so i can use my own custom domain. I added those as vhosts. If you have another HTTP server running somewhere in your network you can point caddy to that remote server as well by specifying the remote. If the remote is empty (like with the home assistants ones) it will point to the docker host (172.17.0.1) by default.
I have redirected in my router 443 to 192.168.0.44 (rpi local ip) port 8123.
I have gafana addon installed on port 3000 (192.168.0.44:3000)
How would do a setup to reach gafana?
I am also struggling to run caddy and the dashboard (AppDaemon) at the same time as they are both on port 80, and the App daemon only works on 80 (cannot modify it according to the manual) so I cannot run Caddy and AppDaemon at the same time.
I am keen to understand how it all works but could not find a good place to see the whole picture.
I think it would be good if someone would explain to a dummy like me how the ports work in the containers as I get really confused, and cannot really work out how to make it all work.
I believe it’s currently not supported to have configure subdirectories with this hassio implementation of caddy. So to get grafana working you should get another domain name with duckdns.
So lets say you have a.duckdns.org for home assistant and b.duckdnsorg for grafana.
You can resolve the conflicting ports with AppDaemon by changing the port of the caddy container from 80 to something else. You can do this in the panel below the caddy configuration json. Then just forward port 80 on your router to port 81 on your rasperry pi.
Then it will route as follows: internet -> router:80 -> rpi:81 -> caddy:80 -> homeassistant:8123 / grafana:3000. Just use a.duckdns.org for home assistant and b.duckdns.org for grafana.
I’m trying to get Caddy setup to work with Node RED and Configurator and while I’m able to access the Hassio frontend I cannot access Node RED or Configurator, they both give me a “502 bad gateway” error. This is how I have the options in Caddy set up. Wondering if someone can point me in the right direction?
Are you running node red on top of hassio as an add-on or is it running elsewhere in the network? If running elsewhere you need to specify the host in your configuration. If not, can you share the port configuration in the add-on configuration?
It’s running as an add-on. Sorry, I’m pretty green to all of this, but I don’t see any port configurations in the node red add on, this is what I have set for the options
Oh, I tried so many combination that now I don’t know how to answer. Everything I did was not working, SO I guess I need a (also simple) tutorial, or sort of