# Rate-limit on specific subpath

**URL:** <https://community.traefik.io/t/rate-limit-on-specific-subpath/1072>\
**Category:** Traefik v1\
**Tags:** kubernetes-ingress\
**Created:** [July 29, 2019, 12:06pm UTC](https://community.traefik.io/t/rate-limit-on-specific-subpath/1072 "2019-07-29T12:06:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![recet](https://avatars.discourse-cdn.com/v4/letter/r/9e8a1a/32.png) [@recet](https://community.traefik.io/u/recet)\
**Post date:** [July 29, 2019, 12:06pm UTC](https://community.traefik.io/t/rate-limit-on-specific-subpath/1072/1 "2019-07-29T12:06:58Z")

</div>

In traefik 1.7.x, is it possible to add ratelimit on a specific subpath, and nowhere else?

for example:

```auto
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: traefik
    traefik.ingress.kubernetes.io/rate-limit: |
      extractorfunc: client.ip
      rateset:
        api-rateset:
          period: 60s
          average: 10
          burst: 20
  name: REDACTED
  namespace: REDACTED
spec:
  rules:
  - host: REDACTED
    http:
      paths:
      - backend:
          serviceName: REDACTED
          servicePort: REDACTED

```

I want the ratelimit to apply only on

```auto
- backend:
          serviceName: REDACTED/HERE/SOMEWHERE/ONLY

```

---

<div class="post-metadata">

**Author:** ![dduportal](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/dduportal/32/4_2.png) [@dduportal](https://community.traefik.io/u/dduportal)\
**Post date:** [July 29, 2019, 12:14pm UTC](https://community.traefik.io/t/rate-limit-on-specific-subpath/1072/2 "2019-07-29T12:14:21Z")

</div>

Hello @recet, I'm not totally sure, but does it work by defining 2 ingress rules?  
The goal is to separate concern: you define the most specific ingress rul to be your (host(`REDACTED`) + pathprefix(`/HERE/SOMEWHERE/ONLY`)),  
which is under rate limiting control,  
and then define a second ingress rule for the rest the host `REDACTED`.

This should work because the priority of matching rules in Traefik `v1.7` are based on the lenght of the rule. so (host + path) has more priority than (host), making the expected behavior. Reference: [https://docs.traefik.io/v1.7/basics/#priorities](https://docs.traefik.io/v1.7/basics/#priorities).

```auto
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: traefik
    traefik.ingress.kubernetes.io/rate-limit: |
      extractorfunc: client.ip
      rateset:
        api-rateset:
          period: 60s
          average: 10
          burst: 20
  name: REDACTED
  namespace: REDACTED
spec:
  rules:
  - host: REDACTED
    http:
      paths:
      - path: /HERE/SOMEWHERE/ONLY
        backend:
          serviceName: REDACTED
          servicePort: REDACTED

```

and

```auto
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: traefik
  name: REDACTED-2
  namespace: REDACTED
spec:
  rules:
  - host: REDACTED
    http:
      paths:
      - backend:
          serviceName: REDACTED
          servicePort: REDACTED

```

Let us know if it is ok?

---

<div class="post-metadata">

**Author:** ![recet](https://avatars.discourse-cdn.com/v4/letter/r/9e8a1a/32.png) [@recet](https://community.traefik.io/u/recet)\
**Post date:** [July 31, 2019, 1:40pm UTC](https://community.traefik.io/t/rate-limit-on-specific-subpath/1072/3 "2019-07-31T13:40:02Z")

</div>

> [@dduportal](#):
>
> - path:

Thanks @dduportal. That works!
