Error while parsing rule Host(`www.xxoo.com`) && PathPrefix(`/`: 1:39: missing ',' before newline in argument list

I now use the traefix + consul method as the gateway, and docker compose to start the relevant business container. The docker compose configuration of the business container is as follows:

version: '3'
services:
  nginx-7890:
    container_name: nginx-7890
    image: nginx 
    ports:
      - 80
    environment:
       - SERVICE_TAGS=traefik.enable=true,traefik.http.routers.myrouter.rule=Host(`www.xxoo.com`) && PathPrefix(`/`,`/(.*)/`) && Headers(`hash`,`7890`)
,traefik.http.routers.myrouter.entrypoints=web,traefik.http.routers.myrouter.service=nginx,traefik.http.routers.myrouter.priority=42,traefik.http.servi
ces.nginx.loadbalancer.server.scheme=http,traefik.http.services.nginx.loadbalancer.healthcheck.hostname=www.xxoo.com,traefik.http.services.nginx.loadba
lancer.healthcheck.path=/,traefik.http.services.nginx.loadbalancer.healthcheck.port=80,traefik.http.services.nginx.loadbalancer.healthcheck.scheme=http
,traefik.http.services.nginx.loadbalancer.healthcheck.timeout=10,traefik.http.services.nginx.loadbalancer.server.port=80,traefik.http.services.myservic
e.loadbalancer.healthcheck.interval=10
    networks:
      - default
    restart: always

WX20200910-222127@2x

From the above figure, you can see that the business container has been registered to the consul

traefik.http.routers.myrouter.rule=Host( www.xxoo.com ) && PathPrefix( / , /(.*)/ ) && Headers( hash , 7890 )
Here, I want to achieve the flow to this container when the domain name, path and header match
However, there is an error in the web interface of traefik. The error is as follows:

WX20200910-222311@2x

Service of docker compose service_tags are separated by commas, and the rule of traefik are also separated by commas, which leads to this error
Now I don't know how to configure it to meet the above requirements. I hope you can help me. Thank you

The service tags env var SERVICE_TAGS value is split on , by Consul, so the behavior is expected because of your rule contains ,.

The PathPrefix regex pattern is not right. Routers | Traefik | v2.2

A PathPrefix rule / means that everything starting with / will be handled so the second element (/(.*)/) seems useless. In fact, you don't need a PathPrefix rule / to handle the domain, maybe I missed something.

traefik.http.routers.myrouter.rule=Host(`www.xxoo.com`) && (PathPrefix(`/`) || PathPrefix(`/{any:.*}/`) && (Headers(`hash`) || Headers(`7890`))

or

traefik.http.routers.myrouter.rule=Host(`www.xxoo.com`) && (Headers(`hash`) || Headers(`7890`))

Thank you very much, i try


According to the configuration you provided, the error in the image has been reported. This header must have two values to satisfy

oops, yes you have to find a way to escape , in this case, if it's possible.

I have tried many ways to solve this problem. Now I don't know how to do it

I have solved the problem
The reason for the problem is that the tags of the register image need to be changed to master

Only the code of master branch can be used to parse service_ tags

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.