You are currently viewing How to Configure a Docker App to a Domain Name

How to Configure a Docker App to a Domain Name

Configuring a Docker application to a domain name can seem daunting, especially when integrating services from multiple providers. In this guide on how to configure a Docker app to a domain name with Cloudflare DNS, we’ll walk you through the process of deploying your Docker app on an AWS EC2 instance and configuring it to use a custom domain name managed by Cloudflare DNS. We will see how to leverage the power of Nginx as a reverse proxy.

Configure a Domain Name to a Docker Container on AWS with Nginx and Cloudflare DNS


For this demonstration, we will use the subdomain below. For the rest of the configurations, replace the subdomain used with your subdomain or domain name. Ensure the following are on check.

  1. Subdomains:
  2. The subdomain should have its DNS settings configured on Cloudflare, with SSL certificates enabled and forced to HTTPS. Update the A record to the IP of your EC2 instance/server
  3. An EC2 instance or any server to run your Docker containers and Nginx. Install docker. See the guide on how to install docker on Linux.

Step 1: Running Docker Containers

First, we’ll run our Docker applications on the specified ports. The docker image used is a Django application. When setting up your container, update the parameters as required. Note: By running the below, you will be able to access the application on http://HOSTIP:8001

docker run --name dtechweb -d -p 8001:8000 dannywangari/dtechnologies:2.0.0

Step 2: Install Nginx

Next, install Nginx on your server to act as a reverse proxy for your Docker applications.

  1. Update your package list and install nginx:
sudo apt update
sudo apt install nginx -y

Step 3: Configure Nginx

Create an Nginx configuration file for each subdomain/domain to route traffic to the appropriate Docker container.

sudo nano /etc/nginx/sites-available/
#add the following
server {
    listen 80;

    location / {
        proxy_pass;   #the port 8001 is the port which you exposed your docker application to on the container
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

Step 4: Enable Nginx Sites

Enable these configurations by creating symbolic links to the sites-enabled directory.

sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

Step 5: Test Nginx Configuration

Check the Nginx configuration for syntax errors:

sudo nginx -t

If the test is successful, restart Nginx to apply the changes:

sudo systemctl restart nginx

If you encounter any errors, review the Nginx error logs and troubleshoot accordingly.


By following these above steps, you have successfully set up Docker applications on a domain/subdomain whose DNS records are being managed on Cloudflare, with Nginx acting as a reverse proxy. This setup ensures that your applications are securely accessible over HTTPS, leveraging Cloudflare’s robust DNS and SSL features.

For further assistance or advanced configurations, feel free to explore the Nginx documentation and Docker documentation.

Make a donation to support us

Web Hosting and email hosting Packages

For web development services, SEO services, Digital marketing strategies, website set up services, web hosting and domain registration; contact Dynamic Technologies.