Enable SSL on docker

On various Hardware and OS systems: pi / windows / routers / nas, etc

Moderator: leecollings

Post Reply
ramseylewis
Posts: 2
Joined: Monday 18 October 2021 11:13
Target OS: Windows
Domoticz version:
Contact:

Enable SSL on docker

Post by ramseylewis »

Hello,

On a windows 10, I have a docker container for domoticz and I wonder how to enable ssl ? even with its a self signed cert.
I added the env variable to my docker-compose "ENV SSL_PORT=443" + and binded the ports as well (will post my docker-compose later), but I can't access domoticz on with https.
Can you help me ?

Thanks
ramseylewis
Posts: 2
Joined: Monday 18 October 2021 11:13
Target OS: Windows
Domoticz version:
Contact:

Re: Enable SSL on docker

Post by ramseylewis »

Hello.

Nobody can help me ? I can't imagine nobody is using ssl on domoticz
User avatar
kiddigital
Posts: 438
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Enable SSL on docker

Post by kiddigital »

Did you test in the running Container that Domoticz is started correctly with SSL enabled?

And did you forward the Container port correctly? How does your compose file look like?
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
palbeda
Posts: 1
Joined: Wednesday 27 September 2023 20:24
Target OS: Linux
Domoticz version:
Contact:

Re: Enable SSL on docker

Post by palbeda »

I was able to get HTTPS running on the latest domoticz/domoticz image, but it was not as simple if it was possible to restart Domoticz from the webinterface, which does not work within Docker.

Steps:
1- Make sure you have a Domoticz container succesfull running with the built in SSL certificates in Docker
2- Prepare your own ssl certificate file and copy this in the running container: sudo docker cp <certificate-name> <running container>:/opt/domoticz/
3- Make a backup of your database to prevent loosing data
4- Stop the running container: sudo docker stop <running container>
5-Commit the running container to a new Docker image: sudo docker commit <running container> <new image name>
6- Make a new container: sudo docker run -d -p 8080:8080 -p 443:443 -v /opt/domoticz/userdata -e TZ=Europe/Amsterdam --name domoticz-new <new-image name>

Without any doubt unnecessary difficult, but I found this procedure after a long search on the internet, so I decided to share. Please post here if you have a more simple procedure that works
User avatar
waltervl
Posts: 5851
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Enable SSL on docker

Post by waltervl »

It should be possible to define the certificate with command ARGS that have to be added to the docker startup environment as
EXTRA_CMD_ARG see

https://hub.docker.com/r/domoticz/domoticz
And
https://www.domoticz.com/wiki/Command_line_parameters
-sslwww port (for example -sslwww 443, or -sslwww 0 to disable https)

-sslcert file_path (for example /opt/domoticz/server_cert.pem)

-sslkey file_path (if different from certificate file)

-sslpass passphrase (to access to server private key in certificate)

-sslmethod method (supported methods: tlsv1, tlsv1_server, sslv23, sslv23_server, tlsv11, tlsv11_server, tlsv12, tlsv12_server)

-ssloptions options (for SSL options, default is 'default_workarounds,no_sslv2,no_sslv3,no_tlsv1,no_tlsv1_1,single_dh_use')

-ssldhparam file_path (for SSL DH parameters)


If no –sslcert parameter is provided, Domoticz will use server_cert.pem from its installation folder
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waltervl
Posts: 5851
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Enable SSL on docker

Post by waltervl »

And additional in this topic also a user enabled ssl on docker viewtopic.php?t=40779
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
redswan
Posts: 16
Joined: Monday 23 October 2017 17:07
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.5
Contact:

Re: Enable SSL on docker

Post by redswan »

Is this topic no longer available, link gives 404 error!
User avatar
gizmocuz
Posts: 2547
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Enable SSL on docker

Post by gizmocuz »

But some hints are already posted above.

Another option is to use NGINX proxy manager (also via docker compose)
With this you can make all your non-ssl services ssl aware with a valid certificate and it's easily to manage
(That is, if you have your own domain)

Anyway, you should be able to modify the docker compose yml file to read

ports:
- "8080:8080"
- "443:443"
- "3201:3201"

And now you should be able to access this with https

you can also use another port, for instance

ports:
- "8080:8080"
- "4443:443"
- "3201:3201"

If your machines IP address if 192.168.0.2, you should be able to access Domoticz via

https://192.168.0.2:4443
Quality outlives Quantity!
User avatar
gizmocuz
Posts: 2547
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Enable SSL on docker

Post by gizmocuz »

We have a default certificate installed that should 'just' work
Quality outlives Quantity!
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Enable SSL on docker

Post by jannl »

I use ssl on a docker container to issue a WOL ping to wake up another system in my network. This because the 'wake on power' option in the BIOS is no longer present.

This is done via self signed certificates. The mentioned command is the only thing that the ssh does, so when I issue a ssh to the host, the command is fired and the ssh connection is closed.

For just using ssh, exec in the container and install ssh. Remember to make it persistent via customstart.sh

Not sure if I was wise enough to save the steps I did

ssh into the docker I would not do. SSH out of the docker is also a cyber risk, hence the certificates and the minimum functionality.

Fot 'fooling' around in the docker container, exec works great.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest