Skip to content
This repository has been archived by the owner on Apr 13, 2020. It is now read-only.

Commit

Permalink
[DCK] Add support of traefik2.1
Browse files Browse the repository at this point in the history
Co-Authored-By: Jairo Llopis <[email protected]>
  • Loading branch information
Ivan Yelizariev and Jairo Llopis committed Jan 28, 2020
1 parent 345a61e commit 35b05ad
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
23 changes: 23 additions & 0 deletions common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,33 @@ services:
labels:
traefik.docker.network: "inverseproxy_shared"
traefik.enable: "true"

# Labels only for Traefik v1
traefik.frontend.passHostHeader: "true"
traefik.longpolling.port: "8072"
traefik.port: "8069"

# Labels only for Traefik v2
traefik.entryPoints.web-secured.address: ":443"
traefik.entryPoints.web.address: ":80"
traefik.http.middlewares.web2web-secured.redirectscheme.scheme: "https"
traefik.http.routers.longpolling.entrypoints: "web-secured"
traefik.http.routers.longpolling.service: "longpolling"
traefik.http.routers.web-secured.entrypoints: "web-secured"
traefik.http.routers.web-secured.service: "odoo"
traefik.http.routers.web-secured.tls.certresolver: "main-acme"
traefik.http.routers.web.entrypoints: "web"
traefik.http.routers.web.middlewares: "web2web-secured"
traefik.http.routers.web.service: "dummy"
# HACK https://github.com/containous/traefik/issues/4863#issuecomment-491453743
traefik.http.services.dummy.loadBalancer.server.url: ""
traefik.http.services.longpolling.loadBalancer.passHostHeader: "true"
traefik.http.services.longpolling.loadBalancer.server.port: "8072"
traefik.http.services.longpolling.loadBalancer.server.scheme: "http"
traefik.http.services.odoo.loadBalancer.passHostHeader: "true"
traefik.http.services.odoo.loadBalancer.server.port: "8069"
traefik.http.services.odoo.loadBalancer.server.scheme: "http"

db:
image: tecnativa/postgres-autoconf:${DB_VERSION}-alpine
shm_size: 512mb
Expand Down
18 changes: 18 additions & 0 deletions prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
default:
inverseproxy_shared:
labels:
# Labels only for Traefik v1
traefik.longpolling.frontend.rule:
"Host:${DOMAIN_PROD};PathPrefix:/longpolling/"
traefik.www.frontend.rule: "Host:${DOMAIN_PROD}"
Expand All @@ -28,6 +29,23 @@ services:
traefik.alt.frontend.redirect.replacement:
"$$1://${DOMAIN_PROD}/$$2"

# Labels only for Traefik v2
traefik.http.middlewares.alt2web.redirectregex.regex: "^(.*)://${DOMAIN_PROD_ALT}/(.*)$$"
traefik.http.middlewares.alt2web.redirectregex.replacement: "$$1://${DOMAIN_PROD}/$$2"
traefik.http.routers.longpolling.rule: "Host(`${DOMAIN_PROD}`) && PathPrefix(`/longpolling/`)"
traefik.http.routers.web-alt-0.entrypoints: "web"
traefik.http.routers.web-alt-0.middlewares: "alt2web"
traefik.http.routers.web-alt-0.rule: "Host(`${DOMAIN_PROD_ALT}`)"
traefik.http.routers.web-alt-0.service: "dummy"
traefik.http.routers.web-secured-alt-0.entrypoints: "web-secured"
traefik.http.routers.web-secured-alt-0.middlewares: "alt2web"
traefik.http.routers.web-secured-alt-0.rule: "Host(`${DOMAIN_PROD_ALT}`)"
traefik.http.routers.web-secured-alt-0.service: "dummy"
traefik.http.routers.web-secured-alt-0.tls.certresolver: "main-acme"
traefik.http.routers.web-secured.rule: "Host(`${DOMAIN_PROD}`)"
traefik.http.routers.web-secured.tls.domains[0].main: "${DOMAIN_PROD}"
traefik.http.routers.web-secured.tls.domains[0].sans: "${DOMAIN_PROD_ALT}"
traefik.http.routers.web.rule: "Host(`${DOMAIN_PROD}`)"
db:
extends:
file: common.yaml
Expand Down
24 changes: 24 additions & 0 deletions test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,20 @@ services:
globalwhitelist_shared:
inverseproxy_shared:
labels:
# Labels only for Traefik v1
traefik.frontend.headers.customResponseHeaders:
"X-Robots-Tag:noindex, nofollow"
traefik.longpolling.frontend.rule:
"Host:${DOMAIN_TEST};PathPrefix:/longpolling/"
traefik.www.frontend.rule: "Host:${DOMAIN_TEST}"

# Labels only for Traefik v2
traefik.http.middlewares.no-robots.headers.customresponseheaders.X-Robots-Tag: "noindex, nofollow"
traefik.http.routers.longpolling.rule: "Host(`${DOMAIN_TEST}`) && PathPrefix(`/longpolling/`)"
traefik.http.routers.web-secured.middlewares: "no-robots"
traefik.http.routers.web-secured.rule: "Host(`${DOMAIN_TEST}`)"
traefik.http.routers.web-secured.tls.domains[0].main: "${DOMAIN_TEST}"

command:
- odoo
- --workers=2
Expand All @@ -53,9 +62,24 @@ services:
labels:
traefik.docker.network: "inverseproxy_shared"
traefik.enable: "true"

# Labels only for Traefik v1
traefik.frontend.passHostHeader: "true"
traefik.port: "8025"
traefik.frontend.rule: "Host:${DOMAIN_TEST};PathPrefixStrip:/smtpfake/"

# Labels only for Traefik v2
traefik.entryPoints.web-secured.address: ":443"
traefik.http.middlewares.smtpfake-stripprefix.stripprefix.prefixes: "/smtpfake"
traefik.http.routers.smtpfake.entrypoints: "web-secured"
traefik.http.routers.smtpfake.middlewares: "smtpfake-stripprefix"
traefik.http.routers.smtpfake.rule: "Host(`${DOMAIN_TEST}`) && PathPrefix(`/smtpfake`)"
traefik.http.routers.smtpfake.rule: "Host(`${DOMAIN_TEST}`)"
traefik.http.routers.smtpfake.service: "smtpfake"
traefik.http.routers.smtpfake.tls.domains[0].main: "${DOMAIN_TEST}"
traefik.http.services.smtpfake.loadBalancer.passHostHeader: "true"
traefik.http.services.smtpfake.loadBalancer.server.port: "8025"
traefik.http.services.smtpfake.loadBalancer.server.scheme: "http"
volumes:
- "smtpconf:/etc/mailhog:ro,z"
entrypoint: [sh, -c]
Expand Down

0 comments on commit 35b05ad

Please sign in to comment.