A docker-compose stack to get portainer running on your home pc / cloud vm, featuring ddns and https
- Reverse proxy to Portainer UI
- Automatic, free SSL certificates provided by Lets Encrypt
- Automatic redirects HTTP calls to HTTPS
- HTTP/2 right out of the box
- GZIP Compression
- Static web site hosting
- Precompressed assets with brotli
- Cache-Control header on jsdos assets
- HTTP/2 Server Push on a big wasm file
- CADDY_CERT_EMAIL=me@example.com
- CADDY_HOSTNAME_PORTAINER=myportainer.ddns.net
- CADDY_HOSTNAME_SITE=mysite.sytes.net
You need to set those ENV variables on your host. You can add them just for one single command or permanently. I will use the first approach.
- Get yourself a dynamic-dns pointing to your public internet IP address. For this example, I will be using https://www.noip.com as my provider and my custom hostnames will be: myportainer.ddns.net and mysite.sytes.net
Create a new A record for myportainer.ddns.net pointing to your external IP.
Create a new CNAME record for mysite.sytes.net pointing to myportainer.ddns.net
- Make sure your home pc is getting assigned a static IP address from your router. The following step depends on this.
For this demo, imagine that your router IP address is 192.168.0.1 and your pc IP address is 192.168.0.2
This is also known as static IP address or IP reservation. This varies depending on the device model and manufacturer, but you can take a look on this guide here
- Add 2 port forwarding rules from the external world to you home pc:
[EXTERNAL] 80 -> 192.168.0.2:80
[EXTERNAL] 443 -> 192.168.0.2:443
-
Make sure you have docker and docker-compose installed
-
Clone this repo
$ git clone https://github.com/raonigabriel/portainer_ddns.git
- Start the stack, passing the variables BEFORE the docker-compose command
$ cd portainer_ddns
$ CADDY_CERT_EMAIL=me@example.com CADDY_HOSTNAME_PORTAINER=myportainer.ddns.net CADDY_HOSTNAME_SITE=mysite.sytes.net docker-compose up -d
- Browse to your portainer at https://myportainer.ddns.net or your site at https://mysite.sytes.net