Traefik,multiple frontend rules to one docker container

Traefik,multiple frontend rules to one docker container



I did search the manual but really couldn't make it very clear, even using the keywords to google that.



I need to proxy the /_ to the API container, some rule like that www.mydomain.com/_ => API container


/_


www.mydomain.com/_ => API container



There is already a specified domain point to this API container
api.mydomain.com => API container


api.mydomain.com => API container



This is my docker-compose.yml, all I want is to add a rule that proxy the /_ to this container too.


docker-compose.yml


/_


version: '3.3'

services:

testapi:

image: git.xxxx.com/api/core/test:latest

restart: always

networks:
- web
- default

expose:
- "80"

labels:
- "traefik.enable=true"
- "traefik.port=80"
- "traefik.docker.network=web"
- "traefik.backend=testapi"
#this domain is used for app
- "traefik.frontend.rule=Host:api.test.mydomain.com"
#this is used for website.All I want is prxy "https://www.test.mydomain.com/_/" to this container
- "traefik.frontend.rule1=Host:www.test.mydomain.com;PathPrefixStrp:/_"




1 Answer
1



You can use segment labels:


version: '3.3'

services:
testapi:
image: git.xxxx.com/api/core/test:latest
restart: always
networks:
- web
- default
expose:
- "80"
labels:
- "traefik.enable=true"
- "traefik.port=80"
- "traefik.docker.network=web"
#this domain is used for app
- "traefik.foo.frontend.rule=Host:api.test.mydomain.com"
- "traefik.bar.frontend.rule=Host:www.test.mydomain.com,m.test.mydomain.com;PathPrefixStrp:/_"



https://docs.traefik.io/v1.6/configuration/backends/docker/#on-containers-with-multiple-ports-segment-labels






Work like a charm

– wanfujinan
Sep 12 '18 at 2:13






Bravo man! Saved my time.

– Taras Vaskiv
Nov 8 '18 at 18:39



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế