Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk10 min

How to Host Multiple Domains on Docker Containers with HTTPS

Serve many domains securely from one Docker server by publishing only a reverse proxy on ports 80 and 443, routing by hostname over a shared network, and persisting ACME certificate state.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The reliable pattern is one public reverse-proxy container in front of private application containers. Publish only TCP ports 80 and 443 from the proxy, attach it and every routed service to a shared Docker network, and route each request by its HTTP Host header. Point every domain’s DNS record at the server before requesting certificates; then let Caddy or Traefik obtain and renew ACME certificates for those hostnames.

This design lets one Docker host serve unrelated domains and subdomains without exposing each application’s port. Caddy uses explicit host blocks, while Traefik discovers Docker services from labels and is better suited to frequently changing stacks.

As an Amazon Associate I earn from qualifying purchases.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The architecture: one edge, many private services

A browser connects to a hostname such as example.com. DNS resolves that name to your server’s public IP. The reverse proxy listens on ports 80 and 443, terminates TLS, reads the request’s hostname, and forwards the request to the matching Docker service over an internal network.

What happens to a request

  1. The client looks up the domain’s A or AAAA record.
  2. The client opens an HTTP or HTTPS connection to the server’s port 80 or 443.
  3. The proxy selects a router using the request hostname, such as example.com or api.example.net.
  4. The proxy serves or obtains the certificate for that hostname, then forwards the decrypted request to the configured container port.
  5. The application responds through the proxy; its container port never needs to be reachable from the public internet.

Which containers are public

Component Public host ports Docker connectivity Purpose
Reverse proxy 80 and 443 Attached to the shared proxy network HTTP routing, TLS termination, redirects, and certificate management
Application services None in the normal design Attached to the shared proxy network Serve sites or APIs on their container ports
Databases and internal workers None Private application networks Remain inaccessible to the edge proxy unless a route is explicitly required

Docker Compose services on a common network resolve one another by service name. A proxy can therefore target app1:8080 rather than a host IP or a published port.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Prerequisites and decisions before deployment

  • A server with a public IP address, Docker Engine, and Docker Compose.
  • An A and/or AAAA DNS record for every hostname, all pointing to that server.
  • Firewall and cloud security-group rules allowing inbound TCP 80 and 443.
  • One shared external Docker network, for example proxy, joined by the proxy and each service it routes.
  • Persistent storage for ACME state and certificates, protected with restrictive permissions and included in backups.
  • A choice between a Caddyfile-based configuration and Traefik’s Docker-label configuration.

Decide whether each hostname is a separate site or an alias. For example, www.example.com can route to the same service as example.com, while api.example.net can target a different service and container port.

Point DNS at the Docker host first

Certificate authorities must be able to resolve and reach the hostname before automated issuance can succeed. Create the DNS records before starting certificate provisioning.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

DNS records to create

Hostname Typical record Destination
example.com A (and optionally AAAA) Your server’s public IPv4 (and IPv6, if configured)
www.example.com A/AAAA or a CNAME to the canonical hostname The same public service
api.example.net A (and optionally AAAA) The same Docker host

An AAAA record is usable only when the server, firewall, Docker host, and proxy are actually reachable over IPv6. A stale or incorrect AAAA record can make a challenge fail even when the A record is correct.

Verify resolution and reachability

  1. Query each hostname from outside the server’s network and confirm it resolves to the intended public address.
  2. Open TCP 80 and 443 in the host firewall and any provider security group.
  3. Ensure no existing web server or other process already owns either host port.
  4. After the proxy starts, test both HTTP and HTTPS for every hostname. A successful DNS lookup alone does not prove that an ACME challenge can reach the proxy.

Create the shared Docker network

Create one external network that can be referenced by separate Compose projects:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
docker network create proxy

Mark the network as external in each Compose file. The proxy and routed services must join the same network; a service attached only to its private application network will not be resolvable by the proxy.

networks:
  proxy:
    external: true
    name: proxy

Use service names, not container IP addresses, in proxy configuration. Docker can replace a container during an update while preserving the service name and network discovery.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Option A: Caddy for explicit host configuration

Caddy’s HTTPS behavior is intentionally simple: when a site block contains a host name, it enables HTTPS automatically, obtains an ACME certificate, and manages renewal as long as the hostname is publicly reachable on ports 80 and 443.

Compose layout

The following layout gives Caddy persistent certificate storage and connects it to the shared network. The application is not published on the host.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
services:
  caddy:
    image: caddy:latest
    restart: unless-stopped
    ports:
      - '80:80'
      - '443:443'
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy_data:/data
      - caddy_config:/config
    networks:
      - proxy

  app1:
    image: your-app-image
    expose:
      - '8080'
    networks:
      - proxy

  api:
    image: your-api-image
    expose:
      - '3000'
    networks:
      - proxy

volumes:
  caddy_data:
  caddy_config:

networks:
  proxy:
    external: true
    name: proxy

expose documents the container port for the Compose network; it does not publish that port on the host. You can omit it when the image already listens on the expected port, but the proxy target must still match the process’s actual listening port.

Write one Caddyfile block per hostname

example.com {
    reverse_proxy app1:8080
}

www.example.com {
    reverse_proxy app1:8080
}

api.example.net {
    reverse_proxy api:3000
}

Each block maps one hostname to an upstream service. Separate blocks make aliases and independent domains obvious; several names can also be listed when they should share exactly the same behavior. Caddy must be able to resolve app1 and api on the proxy network.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Start and validate Caddy

  1. Save the Compose file and Caddyfile in the project directory.
  2. Run docker compose up -d.
  3. Inspect docker compose logs caddy for configuration or ACME errors.
  4. Request each hostname over HTTP and HTTPS. Confirm that HTTP is redirected to HTTPS and that the certificate names the requested host.
  5. Keep the caddy_data volume when recreating or migrating the container; deleting it removes the proxy’s stored certificate state.

Option B: Traefik for Docker-label discovery

Traefik watches Docker metadata and builds routers from labels. This removes the need to edit a central file whenever a service is added, but it introduces more moving parts: entrypoints, certificate resolvers, router rules, and provider permissions.

Proxy service requirements

A Traefik deployment normally needs host entrypoints on 80 and 443, the Docker provider, an ACME certificate resolver, persistent certificate storage, and a connection to the shared network. A representative Compose service is:

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
services:
  traefik:
    image: traefik:latest
    restart: unless-stopped
    command:
      - '--entrypoints.web.address=:80'
      - '--entrypoints.websecure.address=:443'
      - '--providers.docker=true'
      - '--providers.docker.exposedbydefault=false'
      - '--entrypoints.web.http.redirections.entrypoint.to=websecure'
      - '--entrypoints.web.http.redirections.entrypoint.scheme=https'
      - '[email protected]'
      - '--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json'
      - '--certificatesresolvers.le.acme.httpchallenge.entrypoint=web'
    ports:
      - '80:80'
      - '443:443'
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./letsencrypt:/letsencrypt
    networks:
      - proxy

networks:
  proxy:
    external: true
    name: proxy

The Docker socket gives the provider access to container metadata and is sensitive operational data. Keep the proxy host restricted, use the read-only mount shown above where supported, and avoid exposing the Docker API itself.

Label an application service

  app1:
    image: your-app-image
    networks:
      - proxy
    labels:
      - 'traefik.enable=true'
      - 'traefik.http.routers.app1.rule=Host(`example.com`)'
      - 'traefik.http.routers.app1.entrypoints=websecure'
      - 'traefik.http.routers.app1.tls.certresolver=le'
      - 'traefik.http.services.app1.loadbalancer.server.port=8080'

The Host rule selects the domain, websecure selects the TLS entrypoint, and the certificate resolver tells Traefik to obtain the certificate through ACME. The load-balancer port is the port inside the container, not a host-published port.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add another domain or service

  api:
    image: your-api-image
    networks:
      - proxy
    labels:
      - 'traefik.enable=true'
      - 'traefik.http.routers.api.rule=Host(`api.example.net`)'
      - 'traefik.http.routers.api.entrypoints=websecure'
      - 'traefik.http.routers.api.tls.certresolver=le'
      - 'traefik.http.services.api.loadbalancer.server.port=3000'

Router and service names such as app1 and api must be distinct. If an image listens on a different internal port, change the label rather than publishing that port publicly.

Prepare ACME storage

Create the host directory used by the resolver, ensure the proxy can write its state, and back it up. If the state file is lost during a migration, the proxy may need to request certificates again and can encounter certificate-authority rate limits.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How automated HTTPS issuance and renewal works

Both approaches use ACME. The proxy proves control of a hostname by responding to a challenge, stores the resulting certificate and account state, and renews before expiry. Renewal is automatic only while DNS, public reachability, storage, and proxy configuration remain intact.

Conditions required for issuance

  • The hostname resolves publicly to the Docker server.
  • TCP 80 and/or 443 required by the selected challenge is reachable from the internet.
  • The reverse proxy is running and has the route for that hostname.
  • The proxy can write its persistent ACME storage.
  • No second process intercepts the challenge or occupies the published ports.

One certificate versus many names

You can use an individual certificate per hostname, which keeps routing and renewal failures isolated. A certificate can also contain multiple subject-alternative names. The ACME companion documentation used by one common proxy pattern notes a 100-domain certificate limit; certificate-authority policies can change, so verify the current limit before designing a very large SAN certificate. The limit is not a reason to expose application ports or to combine unrelated services.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Renewal-safe operations

  1. Persist the Caddy data volume or Traefik ACME directory outside the disposable container layer.
  2. Back up that state before moving the stack to another host.
  3. Keep DNS records pointed at the active host during a migration, or plan the DNS change before the next renewal window.
  4. After upgrades, test an HTTPS request for every hostname and inspect proxy logs for renewal errors.

Caddy or Traefik: choose by operating model

Decision factor Caddy Traefik
Configuration style One explicit Caddyfile host block per site or alias Docker labels define routers, services, entrypoints, and certificate resolvers
Service discovery Upstream addresses are written explicitly, such as app1:8080 Watches Docker metadata and can reconfigure when labeled services change
TLS setup Hostname blocks trigger automatic HTTPS behavior ACME resolver and TLS router labels are configured explicitly
Best fit A stable set of straightforward host-to-service proxies Frequently changing stacks or deployments needing richer routing and middleware controls
Operational trade-off Fewer TLS and routing settings to maintain More control, with more labels, entrypoints, and provider permissions to audit
Network boundary Only the proxy publishes 80 and 443; backends stay on the shared network Same boundary; the Docker provider also needs access to container metadata

This is an operational comparison, not a performance benchmark. Either proxy can serve many domains from one host when DNS, networking, and certificate prerequisites are satisfied.

Keep application containers private

Do not publish backend ports by default

A Compose mapping such as 8080:8080 opens the application on the host interface. Remove it unless an independent requirement exists. The proxy can reach the same process through app1:8080 on the internal network.

Separate internal networks

Attach a service to the shared proxy network only when it must receive web traffic. Keep databases, queues, and administrative services on a separate private network. A web container can join both networks while the database joins only the private one.

Protect configuration and credentials

  • Use restrictive permissions on ACME state and any mounted configuration containing credentials.
  • Do not expose the Docker daemon’s TCP API.
  • Use read-only mounts for provider metadata access where practical.
  • Apply container updates through a controlled deployment process and test routing afterward.
  • Log proxy access and errors, but avoid placing application secrets in labels or URLs.

Troubleshoot by symptom

Symptom Likely cause Checks and fix
ACME challenge times out DNS points elsewhere, port 80/443 is blocked, or another process owns the port Verify A/AAAA results externally, open firewall and security-group rules, check host listeners, and inspect proxy logs.
Certificate is issued for the wrong name The request reached a different router or the hostname is missing from configuration Check the exact Host rule or Caddy block and confirm that the requested spelling, including www, is configured.
502 or gateway error Proxy and service are not on the same network, the service name is wrong, or the internal port is incorrect Inspect network attachments, resolve the service name from the proxy container, and compare the configured port with the process’s listening port.
HTTP works but HTTPS does not Port 443 is blocked, TLS routing is absent, or certificate issuance failed Test TCP 443, review ACME and router logs, and confirm the HTTPS entrypoint or Caddy hostname block.
HTTPS works until a restart Certificate state was stored only inside the disposable container Mount persistent Caddy data or Traefik ACME storage and restore it before restarting the stack.
One hostname works while another fails Only one DNS record, route, or certificate name was configured Check the failing hostname through DNS, then verify its individual proxy block or labels and its ACME status.
Proxy cannot discover a service Traefik labels are missing or disabled, or the service is not on the shared network Set the enable label, attach the service to proxy, and ensure the router’s service port is the container port.

A repeatable deployment sequence

  1. Reserve the server’s public IP and install Docker Engine and Compose.
  2. Create the external proxy network.
  3. Publish DNS A/AAAA records for every planned hostname.
  4. Allow inbound TCP 80 and 443 and remove competing listeners.
  5. Choose Caddy or Traefik and create persistent ACME storage.
  6. Attach the proxy and only the required application services to proxy.
  7. Configure one host route per domain, using service names and internal container ports.
  8. Start the stack and inspect logs before testing from a browser.
  9. Test HTTP redirection, HTTPS certificates, and application responses for every hostname.
  10. Back up ACME state and document DNS, network, and service-port dependencies before future migrations.

When this pattern needs a different design

A single reverse proxy is appropriate when one Docker host owns the public IP and all domains can reach it. Use a different architecture when domains must terminate in separate security zones, when independent hosts need global load balancing, or when certificate challenges cannot reach the server. In those cases, the same principles still apply—DNS must lead to the active edge, and only the edge should be publicly exposed—but the edge may be a managed load balancer or a separate proxy tier rather than a container on the application host.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.