简体   繁体   中英

Host and Path with Traefik V2

In reference to: Define host and path frontend rule for Traefik (I wanted to comment on the answer but I can't)

I implemented the suggestion in the answer using

Host(`domain.com`) && Path(`/path`)

but it does not work (Getting 404 when trying to access it).

Traefik logs show:

time="2020-07-07T10:31:30Z" level=error msg="field not found, node: rule " providerName=docker

My docker compose looks like this:

deploy:
  labels:
    - "traefik.enable=true"
    - "traefik.http.routers.typo3-${NAMEOFSERVICE}.rule = Host(`${HOSTNAME}`) && Path(`${DIRECTORY}`)"

When just using with the Host rule it works perfectly fine. But I want to be able to do eg subdomain.domain.com/subdirectory for service 1 and subdomain.domain.com/subdirectory2 for service 2

I also tried - "traefik.http.routers.typo3-${NAMEOFSERVICE}.rule = Host(`${HOSTNAME}`) && PathPrefix(`${DIRECTORY}`)" but I get the same error in the log and 404.

I found the Problem: remove the spaces around the "="

This works:

- "traefik.http.routers.typo3-${NAMEOFSERVICE}.rule=(Host(`${HOSTNAME}`) && Path(`${DIRECTORY}`))"

I now have another problem. My service in this subdirectory, redirects outside of it. (Example, Typo 3 first install: I access subdomain.domain.com/foo and it redirects me to subdomain.domain.com/typo3/install.php)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM