Error while parsing rule Host() && (PathPrefix(): 1:24: expected ')', found newline

is this a bug?
i notice that it is very strict on using the werid quote "`"
syncCatalog can detect the rules but consul connect cannot detect the rules

traefik.enable=true,traefik.http.routers.static.rule=Host(webservice.domain) && (PathPrefix(/siteone)

but it comes out as

traefik.enable=true
traefik.http.routers.static.rule=Host() && (PathPrefix()
traefik.http.routers.static.entrypoints=web
traefik.http.services.static.loadbalancer.server.port=8080

is there a way to escape the " " ?


I also notice even though it shows an error, the pathprefix does work.

This particular error is related to the ( before PathPrefix, it does not have a matching ). I would just remove the (.

I don't have experience with consul + traefik (yet) so I cannot add any thing there sorry.

I tried removing () and uses like Host:localhost but traefik dashboard doesn't like it.
Note that i am using helm and kubernetes. Also use kubernetes yaml to implement these tests.

have you try to put double quotes around the tags

"traefik.enable=true","traefik.http.routers.static.rule=Host(`webservice.domain`) && PathPrefix(`/siteone`)"

you can also use escaped double quote instead of backtick:

traefik.enable=true,traefik.http.routers.static.rule=Host(\"webservice.domain\") && PathPrefix(\"/siteone\")

FYI backticks are use in a lot a things like: Markdown, Bash, Javascript, Go, etc.

2 Likes

When i tried with quotes around each:
consul.hashicorp.com/service-tags: "traefik.enable=true","traefik.http.routers.demo-web.rule=PathPrefix(/v1)","traefik.http.routers.demo-web.entrypoints=web"

I get a error: error parsing consul_demodeploy.yaml: error converting YAML to JSON: yaml: line 26: did not find expected key
so it doesn't allow that type of syntax

When i used:
"traefik.enable=true,traefik.http.routers.demo-web.rule=PathPrefix("/v1"),traefik.http.routers.demo-web.entrypoints=web".
it does show up as valid in traefik's dashboard but it disappears in a few seconds


in consul dashbaord, it outputs like =PathPrefix("/v1")
But why does it disappear in the http routers? The services shows the loadbalancer type but the router rule part disappears. Note i only added the annontations in the deployment, not the services.

edit:
after i add a loadbalancer service, the pathprefix("v1") now does not disappear.

Thanks Idez. I think that solved one probem. I appreciate your help!