I'm always excited to take on new projects and collaborate with innovative minds.

Phone

+855 12 282 686

Email

samnangrosady9@gmail.com

Social Links

Tutorials

A Guide to Setting Up Local HTTPS Portals with Docker

Mimicking production environments with HTTPS setups ensures more accurate testing, reducing the likelihood of issues when deploying to live servers.

A Guide to Setting Up Local HTTPS Portals with Docker

A Guide to Setting Up Local HTTPS Portals with Docker

Understanding Local HTTPS Portals

Local HTTPS portals enable developers to create secure connections within their development environments. By utilizing HTTPS, data transmitted between services remains encrypted, safeguarding sensitive information from potential security threats.

Why Use Local HTTPS Portals with Docker?

  1. Enhanced Security: HTTPS encryption protects data integrity and confidentiality, crucial for handling sensitive information during development.
  2. Realistic Testing Environment: Mimicking production environments with HTTPS setups ensures more accurate testing, reducing the likelihood of issues when deploying to live servers.
  3. Streamlined Development Workflow: Docker's containerization capabilities facilitate easy setup and teardown of services, making it effortless to create and manage secure development environments.
  4. Collaboration and Consistency: By standardizing HTTPS setups with Docker, developers can collaborate seamlessly and ensure consistent configurations across team members.

Practice

Imagine you have local services frontend and API running on ports 3000 and 3001, respectively. You want to set up a local HTTPS portal using Docker to secure these services. You want access https://api.local.test for the API and https://front.local.test for the frontend.
Screenshot 2025-05-02 at 9.50.59 AM
 

Docker

  • docker-compose.yml Create a docker-compose.yml file to define the services and their configurations.
services:
  frontend:
    container_name: frontend
    image: nginxdemos/hello
    ports:
      - "3000:80"
  api:
    container_name: api
    image: nmatsui/hello-world-api
    ports:
      - "3001:3000"
  https-portal:
    image: steveltn/https-portal:1
    ports:
      - "80:80"
      - "443:443"
    restart: always
    environment:
      DOMAINS: 'api.local.test -> http://api:3001, front.local.test -> http://frontend:80'
    volumes:
      - https-portal-data:/var/lib/https-portal
volumes:
  https-portal-data:

Update your system's hosts file to point the domains to your Docker host

  • Linux/MacOS
echo "127.0.0.1       local.test api.local.test" | sudo tee -a /etc/hosts
  • Windows: On Windows: Add these lines to C:\Windows\System32\drivers\etc\hosts
127.0.0.1 local.test
127.0.0.1 api.local.test

Run

docker compose up -d

🌟 Stay tuned 🌟

Full content:Dev.to

2 min read
May 02, 2025
By Samnang Rosady
Share

Related posts

Aug 15, 2025 • 1 min read
Redis Commander

redis commander: redis monitoring tool

May 08, 2025 • 3 min read
Jinja: The Templating Wizard That Saves Devs From Keyboard Trauma

Jinja: template engine

Mar 24, 2025 • 2 min read
Rclone: Cloudflare R2 and Nginx Reverse Proxy

Rclone with Cloudflare R2 and Nginx reverse proxy for enhanced cloud s...