Coder Social home page Coder Social logo

local-traefik's Introduction

Traefik v2 HTTPS SSL Localhost

This project provides a Docker Compose template for setting up Traefik v2 with HTTPS and SSL support for localhost. It also includes an example template for setting up multiple Postgres connections.

Setup

To get started, create a Docker network using the following command:

# Create a Docker network
docker network create traefik

You will also need to generate SSL certificates for the domain "docker.localhost" and "domain.local" along with their sub-domains. You can use mkcert to generate the certificates. Install mkcert using the command mkcert -install and then generate the certificates using the following command:

# Generate certificates
mkcert -cert-file certs/local-cert.pem -key-file certs/local-key.pem "localhost" "*.localhost" "localhost"

Make sure to place the generated certificates in the certs directory of this project.

Multiple Postgres Connections

You can use the provided Docker Compose template to set up multiple Postgres connections. Here's an example template for the Postgres service:

services:
  db:
    hostname: ${POSTGRES_HOST}
    image: postgres:12.0-alpine
    restart: unless-stopped
  
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-user}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
      POSTGRES_DB: ${POSTGRES_DB:-db}

    labels:
      - traefik.enable=true
      - traefik.tcp.routers.postgres.tls=true
      - traefik.tcp.routers.postgres.rule=HostSNI(`${DB_HOST}`)
      - traefik.tcp.routers.postgres.entrypoints=postgres
      - traefik.tcp.services.postgres.loadbalancer.server.port=5432
  
    expose:
      - 5432

    networks:
      - traefik

This template sets up a Postgres service with Traefik labels for enabling HTTPS, SSL, and routing based on the Host SNI (Server Name Indication) header. It also exposes port 5432 and connects to the traefik Docker network.

Don't forget to add the $POSTGRES_HOST to your /etc/hosts file.

local-traefik's People

Contributors

a avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.