Today in our NGINX Proxy Manager Tutorial which is Episode 7 in our Raspberry Pi Series. We will be looking at how to set up a fully qualified domain name (FQDN) that will point to our Raspberry Pi and will work with our Docker container applications.
Difficulty = Medium
What is Dynamic DNS?
With most home internet services providers (ISP), they allocate to their customers a dynamic IP addresses. What this means is the public IP address assigned to your home internet connection will change in line with a lease period.
What else can make your IP change?.
What can also cause an IP change is if your Internet Router or Modem has to be restarted. A fresh Public IP address will then be assigned.
This becomes a problem for a home server environment because the IP address that has changed will need to be updated with the domain registrar in the form of an A entry.
If this update does not occur then your domain visitors will be unable to make a connection with your network/service and the only way to re-establish this would be to manually update the A Entry with the new IP address at the domain registrar.
To do this manually every time the IP changes would be impractical so we will need to automate the process. This is where DuckDNS comes in.
Do I have to use DuckDNS?
There are exceptions and times that a DDNS service would not be required and this mostly occurs in the business world. Your ISP can issue your network with a static public IP address which means your IP address will never change.
This service is usually a paid-for extra. However, if your IP doesn’t change you should check with your ISP to confirm your IP is static before setting up any direct public-facing server or service.
Duckdns does not require the use of a private domain name. It uses subdomains to forward its DDNS service. If you are looking to use your own private domain then I would recommend using Cloudflare rather than DuckDNS.
So in a nutshell if your ISP has issued you with a Static IP. You do not need to use any DDNS services including DuckDNS.
Our Dynamic DNS solution
We will require an additional Docker container that will monitor your Public IP address locally for any changes. If it notices that your Public IP has changed it will automatically update the IP A record on the online DuckDNS service website.
DUCKDNS Installation Guide
Step 1: Set up a Duckdns account.
The First thing to do will be to set up a DuckDNS account which is easy.
Just navigate to their homepage and log in using one of the many sign in options they offer. In our example we use Google.
Step 2: Enter a Duckdns subdomain.
Once logged in we are going to create a subdomain by entering into the white box a name you would like to use for your service.
Note: You will need to create a new subdomain for each docker container service you host.
In our example, we just put in “a2t“. Then click on the green “add domain” button.
This now gives us a domain name to use. In our case it is a2t.duckdns.org.
The DuckDNS service will automatically take the public IP address you are currently on and add this to the IP field. If you are using a VPN, proxy or are using any other network that is different from the one you want to host your service on you will need to update this IP manually to start with to ensure the correct IP address is used. (This will be auto-updated later by our DuckDNS container either way).
Step 3: Create and deploy the Duckdns container using a stack.
Now we have our subdomain we are going to “log in” to our “Portainer” dashboard on our Raspberry Pi and navigate to the “Stacks” page:
From there we are going click on the “Add stack” button.
This will open up a new Stack creation window. We will then name our stack “duckdns“
Then in the Web editor we will paste the following Docker compose data into the empty field.
Docker Compose Stack:
--- version: "2.1" services: duckdns: image: ghcr.io/linuxserver/duckdns container_name: duckdns environment: - PUID=1000 #optional - PGID=1000 #optional - TZ=Europe/London - SUBDOMAINS=subdomain1,subdomain2 - TOKEN=token - LOG_FILE=false #optional volumes: - /path/to/appdata/config:/config #optional restart: unless-stopped
You will then need to change the fields to match your installation. If you would like to use a specific user account then you will need to find the PUID and GUID of that user account. We have shown how to do this in our Youtube Video so please watch that. If you would like to go with the defaults just remove both these fields as they are optional.
Set your timezone “TZ” to your current location.
Add your subdomain name to the “SUBDOMAIN” field. If you have more than one you will need to add an entry for each subdomain you wish to use and separate them with a comma.
Note you do not need to add the full domain name only the subdomain part. In our example, we would only put “a2t” into the “SUBDOMAIN” field. not a2t.duckdns.org.
Add your Token to the TOKEN field, which can be found on the Duckdns subdomain creation page at the top right. This is unique to every user and only needs to be put in once regardless of how many subdomains you use.
If you would like to use logs then you can change the field to “true” this is optional.
Under Volumes add the location of where you install all your Docker data.
Now you have set them fields your Docker compose Stack should look something like this:
Now you have confirmed all is set up correctly you can press the “Deploy the stack” button.
You can now check the Portainer containers page to confirm the “duckdns” container has been created correctly.
Press the Logs button to check all is as expected. It should look like this:
To confirm your domain is working correctly you can open a browser window and enter your domain name into the address field.
You should now see this:
This concludes today’s Tutorial.
In our next episode, we will be installing and configuring Nginx Proxy Manager to use Cloudflare’s DDNS service and setting a custom Domain. Don’t miss out! Subscribe to your Youtube channel and click the notification bell to be notified when new content goes live.
We need your support.
We hope you enjoyed this episode and that it was helpful and you got benefit out of it.
If you did, please consider supporting our channel by Subscribing to our YouTube channel, and liking and sharing our content.
If you have any questions or any requests please ask in the comments below or on YouTube.