Skip to content

Instantly share code, notes, and snippets.

@yangxuan8282
Last active June 27, 2017 16:09
Show Gist options
  • Save yangxuan8282/2da173f938adcbcc429ed2555e1c144e to your computer and use it in GitHub Desktop.
Save yangxuan8282/2da173f938adcbcc429ed2555e1c144e to your computer and use it in GitHub Desktop.
tmp use

traefik/docker-compose.yml

version: '2'

services:
  proxy:
    image: traefik
    networks:
      - webgateway
    ports:
      - "80:80"
      - "443:443"
    restart: always
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "./traefik.toml:/traefik.toml"
    labels:
      - "traefik.backend=proxy"
      - "traefik.frontend.rule=Host:traefik.mydomain.com"
      - "traefik.port=8080"

networks:
  webgateway:
    driver: bridge

traefik/traefik.toml

# defaultEntryPoints must be at the top because it should not be in any table below
#defaultEntryPoints = ["http", "https"]
defaultEntryPoints = ["http"]

[web]
# Port for the status page
address = ":8080"

# Entrypoints, http and https
[entryPoints]

# http should be redirected to https
[entryPoints.http]
address = ":80"
#[entryPoints.http.redirect]
#entryPoint = "https"

# https is the default
#[entryPoints.https]
#address = ":443"
#[entryPoints.https.tls]

# Enable ACME (Let's Encrypt): automatic SSL
#[acme]
# caServer = "https://acme-staging.api.letsencrypt.org/directory"
#email = "[email protected]"
#storage = "acme.json" # or "traefik/acme/account" if using KV store
#entryPoint = "https"
#onDemand = false
#OnHostRule = true


[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "mydomain.com"
watch = true
#exposedbydefault = false

app/docker-compose.yml

version: "2"

services:
  api:
    image: 
    networks:
      - web
    labels:
      - "traefik.backend=api"
      - "traefik.port=8082"
      - "traefik.frontend.rule=Path:/rpc"

  upload:
    image:
    networks:
      - web
    labels:
      - "traefik.backend=upload"
      - "traefik.port=5052"
      - "traefik.frontend.rule=Path:/upload"

  front:
    image:
    networks:
      -web
    labels:
      - "traefik.backend=front"
      - "traefik.port=80"
      - "traefik.frontend.rule=Host:front.mydomain.com"
      
networks:
  web:
    external:
      name: traefik_webgateway
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment