The first proper post of the blog is something I don't do frequently: playing with the web. In this post, I'll explain how after some hours I got the blog running with a custom domain and SSL using docker in a qnap NAS. The process should work on any NAS (with Synology it could be even easier) but I'll explain it using the Qnap process.
The first thing you have to install (if you don't have it yet) is Container Station. Just install it from the app center.
You'll need 3 different folders on your NAS. Place them where you want to. In my case I created this shared folders with inner subfolders:
ContainerData is just for configuration and storage for the docker image and WebServer will be the root of the Caddy server, anything we place there will be server from Caddy.
Caddy is the key part of the process. It's a really simple web server and reverse proxy that creates certificates from let's encrypt automatically. The first step will be installing Caddy docker image on Container Station. If you are running the setup process for the first time it's possible you won't get the configuration loaded. In that case: create a container, delete and start the container creation again.
You'll have to setup:
We almost have Caddy ready, now we just need to create a new file named Caddyfile without extension inside the conf folder. The content, for example, could be:
yourowndomain.com {
tls youremail
root /srv
browse
log stdout
errors stdout
}
Save it and restart your container. Caddy should start and it will register a new SSL certificate for your domain. Magic!
You'll have to redirect the ports you set up when creating the container. You have to redirect the external 80 port to the port you mapped to the docker 80 port and the same with 443. Your NAS will use custom ports but both external and docker internal ports should match.
There's only one missing part: the domain. You'll need to configure your domain to point to your DDNS host. If you have a fixed external IP just use that IP. In my case, I'm using name.com and the qnap DDNS.
At this point, you have everything ready. Your NAS is serving a static site with SSL. Serving dynamic content either from another service on your NAS on from another docker you'll have to use the IP. Don't use localhost, use the IP instead. For example:
yourcustomdomain.com {
tls youremail@here.com
proxy / https://192.168.1.57:4433 {
insecure_skip_verify
transparent
}
}
This will allow you to proxy your domain to a different IP while keeping the SSL. Magic, again.