<p>I am using traefik 2.2.1 as my kubernetes ingress controller. Now I have a url need to forward, this is my traefik config right now:</p>
<pre><code>apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  creationTimestamp: '2021-09-26T09:10:02Z'
  generation: 4
  name: uat-zhuolian-manage-route
  namespace: dabai-uat
  resourceVersion: '106700291'
  selfLink: &gt;-
    /apis/traefik.containo.us/v1alpha1/namespaces/dabai-uat/ingressroutes/uat-zhuolian-manage-route
  uid: d0b82fab-cd6a-49f0-96dc-f6c0f381bcc5
spec:
  entryPoints:
    - web
  routes:
    - kind: Rule
      match: Host(`zhuolian-pro-manage.example.com`)
      services:
        - name: be-zhuolian-frontend
          port: 80
    - kind: Rule
      match: Host(`zhuolian-pro-manage.example.com`) &amp;&amp; Path(`/service`)
      services:
        - name: soa-zhuolian-service
          port: 11032
</code></pre>
<p>what I want the traefik to do is that forward the example.com to <code>be-zhuolian-frontend</code> by default. If the request url contains <code>service</code>, for example the url <code>xxx.example.com/service/foo/bar</code>, forward to the backend service <code>soa-zhuolian-service</code>. but now when I request to the url from remote cloud host:</p>
<pre><code>curl --header 'Host:zhuolian-pro-manage.example.com' http://172.19.104.230/service/zhuolian/report/user/captcha -L
</code></pre>
<p>shows error:</p>
<pre><code>[root@fat001 ~]# curl --header 'Host:zhuolian-pro-manage.example.com' http://172.19.104.230/service/zhuolian/report/user/captcha -L
&lt;html&gt;
&lt;head&gt;&lt;title&gt;404 Not Found&lt;/title&gt;&lt;/head&gt;
&lt;body&gt;
&lt;center&gt;&lt;h1&gt;404 Not Found&lt;/h1&gt;&lt;/center&gt;
&lt;hr&gt;&lt;center&gt;nginx/1.19.0&lt;/center&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>it seems the url with <code>service</code> keywords still route to the frontend service, what should I do to fix this problem and make the <code>service</code> match to the backend service successfully?</p>

Dolphin
<p>use <code>PathPrefix</code> not <code>path</code>, from official document:</p>
<blockquote>
<p>Use Path if your service listens on the exact path only. For instance,
Path: /products would match /products but not /products/shoes.</p>
<p>Use a <em>Prefix</em> matcher if your service listens on a particular base
path but also serves requests on sub-paths. For instance, PathPrefix:
/products would match /products but also /products/shoes and
/products/shirts. Since the path is forwarded as-is, your service is
expected to listen on /products.</p>
</blockquote>
<p>so tweak the config like this:</p>
<pre><code>spec:
  entryPoints:
    - web
  routes:
    - kind: Rule
      match: Host(`zhuolian-pro-manage.example.com`) &amp;&amp; PathPrefix(`/service`)
      middlewares:
        - name: service-stripprefix
      services:
        - name: soa-zhuolian-service
          port: 11032
    - kind: Rule
      match: Host(`zhuolian-pro-manage.example.com`)
      services:
        - name: be-zhuolian-frontend
          port: 80
</code></pre>
