Error while parsing rule Host(``) && 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'
    container_name: nginx-7890
    image: nginx 
      - 80
       - SERVICE_TAGS=traefik.enable=true,traefik.http.routers.myrouter.rule=Host(``) && PathPrefix(`/`,`/(.*)/`) && Headers(`hash`,`7890`)
      - default
    restart: always


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

traefik.http.routers.myrouter.rule=Host( ) && 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:


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.

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(``) && (PathPrefix(`/`) || PathPrefix(`/{any:.*}/`) && (Headers(`hash`) || Headers(`7890`))


traefik.http.routers.myrouter.rule=Host(``) && (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.