20

Localdots – HTTPS domains for localhost with autoconfig and hot reload

 4 years ago
source link: https://github.com/luisfarzati/localdots
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

localdots — HTTPS domains for development

Important

As the title says, this tool is to be used for development. It is not meant to run at production and it hasn't been tested in CI environments either.

Please help report any issues!

Features

localdots combines Caddy and smallstep/certificates with automated configuration and hot reload.

  • Generates SSL/TLS certificates automatically
  • Reloads Caddy automatically with every change

Usage

# docker-compose.yaml

version: "3"

services:
  proxy:
    image: rnbw/localdots
    ports:
      - 80:80 # for http->https redirection
      - 443:443
    volumes:
      # contains all vhost files
      - ./caddy.d:/caddy.d:ro
      # contains CA config and certs
      - ~/.caroot:/caroot
    # only needed for *.localhost domains
    extra_hosts:
      - "whoami.localhost:127.0.0.1"    

  # example containers
  whoami:
    image: jwilder/whoami
  hello:
    image: nginxdemos/hello
# ./caddy.d/whoami.localhost
whoami.localhost {
  proxy / whoami:8000
}

# ./caddy.d/hello.dev
hello.dev {
  proxy / hello
}
# run all the things
docker-compose up -d

# add the domains to your /etc/hosts file
# *.localhost domains shouldn't need to be added
127.0.0.1  hello.dev

# after localdots container is up and running,
# you will see a .caroot directory in your $HOME.
brew install step \
    && step certificate install ~/.caroot/certs/root_ca.crt

# that's it, try open the sites configured above
open https://whoami.localhost
open https://hello.dev

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK