A Guide to Setting Up Local HTTPS Portals with Docker
samnang rosady

samnang rosady @medrix

About: 👨‍💻 Fullstack dev by day, 🌃 IT server whisperer by night | Sharing my knowledge on frontend, backend, devops, and even a sprinkle of infrastructure.

Location:
Phnom Penh, Cambodia
Joined:
Jul 12, 2024

A Guide to Setting Up Local HTTPS Portals with Docker

Publish Date: May 2
0 0

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

Image description
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.

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:
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
  • 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
Enter fullscreen mode Exit fullscreen mode

Run

docker compose up -d
Enter fullscreen mode Exit fullscreen mode

Enjoy you practice 🌟

Comments 0 total

    Add comment