Home Assistant Docker SSL in on Unraid

 
 
 

Preface and Prerequisites

I spent way too long trying to figure this out. I did initially try doing this using Swag and NGINX but I eventually found an easier way to add SSL to my Home Assistant docker instance on unraid and I'm going to detail this below.

Now before we start you will need the below already set up

  • Swag docker container set up correctly and creating certificates with the subdomain you want home assistant to use.

  • Home Assistant set up and working with its own fixed IP address.

  • The User scripts plugin installed on your Unraid Server.

Setting up a job to copy the certificate and key to Home Assistant

Log into your Unraid Server and then go to plugins and open User Scripts. And in the bottom left click on the “Add New Script” button.

A new window will open, enter the name Home Assistant then click ok.

Now find this script on the screen click on the cog on the left and select “Edit Script”

Now below #! /bin/bash copy the below

cp /mnt/user/appdata/swag/keys/letsencrypt/fullchain.pem /mnt/user/appdata/homeassistant/fullchain.pem

cp /mnt/user/appdata/swag/keys/letsencrypt/privkey.pem /mnt/user/appdata/homeassistant/privkey.pem

Hit “Save Changes” and it will take you back to the user scripts page. Hit the Run Script button next to your new script. This will copy the files for the next step. And lastly on the dropdown no the right of your script change that to Scheduled Daily.

Adding HTTPS port to the home assistant docker

Head over to your docker tab and left click on your home assistant docker and click edit. On the new screen that opens scroll to the bottom and click on “Add other Path, Port, Variable, Label or Device” and change the below settings.

Config Type: Port

Name: https

Host port: 443

Default value: 443

Connection type: TCP

And click add. Then at the bottom click apply.

Adding SSL configuration to Home Assistant

In unraid open the Terminal (top right of the screen) and type in the below command

nano /mnt/user/appdata/homeassistant/configuration.yaml


And paste in the below at the bottom of the file.

http:

 server_port: 443

 ssl_certificate: /config/fullchain.pem

 ssl_key: /config/privkey.pem

Hit ctrl+x this will bring up the file name at the bottom, Hit enter and it will now prompt you to overwrite the file hit y and enter again. 

Now restart Home Assistant. The port for access is now the HTTPS port so instead of using http://<ip of server>:8123 you will now type https://homeassistant.<yourdomain>.