Secure external access on Synology in Docker, Letsencrypt, Duckdns Reverse proxy

Hi Everyone,

After many days of trying to make my HA securely accessible from an external source I feel I"m almost there. I hope anyone here can help me with the final part!

Goal
I’m running Home Assistant 103.2 in Docker. My goal is to register whether people are home using the IOS app. Access to HA from outside of my house is bonus.

What I managed to do
I’ve followed the walk through below and managed to i) obtain an URL from duckdns that updates through DDNS ii) used it to gain a certificate from Let’s encrypt and iii) forwarded ports 443, 80 and the HA port to the NAS.

The duckdns URL returns webstation in https with the certificate and in http returns HA when the port is added

Problem
Using a reverse proxy routing HTTPS 443 to the local HA adress should finish it. The problem is that when i fill in the duckdns URL it returns “the domain name is already used, please use another name”. There is no other reverse proxy there, I tried restarting the NAS and cannot find any solution on the internet.

The strange thing is that when i put “www” in front of the URL in the reverse proxy the reverse proxy does accept the URL. When I enter https://www.domain.duckdns.org HA works with certificate! But only from my home, from another location the page is blocked indicating that the certificate is issued for a different domain.

My main question is if anyone has encountered (and solved!) the reverse proxy problem. I’m also very open to other ways to achieve my goal. I’ve also explored copying the certificates to the HA directory to invoke them directly from HA but as soon as I uncomment the SSL lines HA does not start at all anymore with no log to debug.