# Consul Catalog routing via static configuration

**URL:** <https://community.traefik.io/t/consul-catalog-routing-via-static-configuration/7041>\
**Category:** Traefik v2\
**Tags:** consul-catalog, tcp\
**Created:** [July 23, 2020, 8:14am UTC](https://community.traefik.io/t/consul-catalog-routing-via-static-configuration/7041 "2020-07-23T08:14:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Legogris](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@Legogris](https://community.traefik.io/u/Legogris)\
**Post date:** [July 23, 2020, 8:14am UTC](https://community.traefik.io/t/consul-catalog-routing-via-static-configuration/7041/1 "2020-07-23T08:14:24Z")

</div>

I have numerous entrypoints (tcp, udp and https(s)) and services from consul catalog routed via tags, all working fine.

Now I have a service in Consul that is provided by a vendored software, where I have no control over the tag values. In this case, it is a database service where each instance has either the tag `active` or `replica`. I'd like to have a TCP router for a specific entrypoint to this service.

Without any traefik-specific tags on the service, Traefik automatically creates HTTP services and routers. Can I override thisspecific service via static configuration (or COnsul KV) in any way? The "labels" mentioned in [https://docs.traefik.io/reference/dynamic-configuration/consul-catalog/](https://docs.traefik.io/reference/dynamic-configuration/consul-catalog/) seem to be ignored when specified in the configuration file and only picked up via tags on the Consul services.

Is there any way I can do what I want, or do I need to spin up a secondary traefik instance only for this use-case?

---

<div class="post-metadata">

**Author:** ![zespri](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/zespri/32/310_2.png) [@zespri](https://community.traefik.io/u/zespri)\
**Post date:** [July 23, 2020, 9:57am UTC](https://community.traefik.io/t/consul-catalog-routing-via-static-configuration/7041/2 "2020-07-23T09:57:17Z")

</div>

Can you describe what you mean by "override this specific service via static configuration"? Override in which way? Can you give an example?

**Update** : sorry, I did not notice " I'd like to have a TCP router for a specific entrypoint to this service." It makes sense.

I personally never used consul catalog, but I wonder can you do what you want by providing configuration via [File Provider](https://docs.traefik.io/reference/dynamic-configuration/file/) instead for that?

---

<div class="post-metadata">

**Author:** ![Legogris](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@Legogris](https://community.traefik.io/u/Legogris)\
**Post date:** [July 23, 2020, 10:01am UTC](https://community.traefik.io/t/consul-catalog-routing-via-static-configuration/7041/3 "2020-07-23T10:01:46Z")

</div>

So let's say for example I have a consul service `foo` with two instances, one with tag `bar` and one with tag `baz`.

I have a configured endpoint in traefik:

```auto
[entrypoints.foo]
address = "192.168.1.2:1337

```

I'd like to route the `foo` endpoint to the `foo` service, iff the service instance has the `bar` tag set.

I understand I can use constraints (which are global so a bit cumbersome, but should be possible) to limit which instance gets routed.

However, I see no way of avoiding Traefik routing this as a HTTP service rather than TCP without using service tags.

---

<div class="post-metadata">

**Author:** ![Legogris](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@Legogris](https://community.traefik.io/u/Legogris)\
**Post date:** [July 23, 2020, 10:03am UTC](https://community.traefik.io/t/consul-catalog-routing-via-static-configuration/7041/4 "2020-07-23T10:03:41Z")

</div>

> [@zespri](#):
>
> I personally never used consul catalog, but I wonder can you do what you want by providing configuration via [File Provider](https://docs.traefik.io/reference/dynamic-configuration/file/) instead for that?

That's pretty much what I'm trying to achieve actually, but after quite a bit of trial and error I still can't get Traefik to recognize my Consul service through the file provider - it's still gets designated as HTTP

---

<div class="post-metadata">

**Author:** ![zespri](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/zespri/32/310_2.png) [@zespri](https://community.traefik.io/u/zespri)\
**Post date:** [July 23, 2020, 10:07am UTC](https://community.traefik.io/t/consul-catalog-routing-via-static-configuration/7041/5 "2020-07-23T10:07:57Z")

</div>

Are you saying you create a `[tcp.routers]` but you believe that http router is being created instead?

---

<div class="post-metadata">

**Author:** ![Legogris](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@Legogris](https://community.traefik.io/u/Legogris)\
**Post date:** [July 23, 2020, 10:18am UTC](https://community.traefik.io/t/consul-catalog-routing-via-static-configuration/7041/6 "2020-07-23T10:18:11Z")

</div>

Yes, even though I'm referencing the consul service by name. Verified this through the web dashboard.

---

<div class="post-metadata">

**Author:** ![Legogris](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@Legogris](https://community.traefik.io/u/Legogris)\
**Post date:** [July 23, 2020, 10:19am UTC](https://community.traefik.io/t/consul-catalog-routing-via-static-configuration/7041/7 "2020-07-23T10:19:21Z")

</div>

I just ended up solving this for myself by forking the software producing the service and hardcoding the traefik tags there - but I'm sure this is not an all-to-uncommon use-case for others.

---

<div class="post-metadata">

**Author:** ![zespri](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/zespri/32/310_2.png) [@zespri](https://community.traefik.io/u/zespri)\
**Post date:** [July 23, 2020, 11:56pm UTC](https://community.traefik.io/t/consul-catalog-routing-via-static-configuration/7041/8 "2020-07-23T23:56:52Z")

</div>

> Yes, even though I'm referencing the consul service by name. Verified this through the web dashboard.

Are you specifying provider name?

> **[Traefik Proxy HTTP Middleware Overview - Traefik](https://doc.traefik.io/traefik/v2.2/middlewares/overview/)**
>
> Read the official Traefik Proxy documentation for an overview of the available HTTP middleware.
