Comments (3)
@youkoulayley Didn't get a chance before you closed, yes. That worked.
from traefik.
Hi @Bugs5382,
Thanks for your interest in Traefik!
PathPrefix
doesn't support regexp in v3, you have to use PathRegexp
to use regexp now (https://doc.traefik.io/traefik/v3.0/routing/routers/#path-pathprefix-and-pathregexp).
Here's how I rewrote your IngressRoute for my test (I focused exclusively on the frontend part on my tests and used two different whoami
to see if the routing seems correct):
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: web
namespace: default
spec:
entryPoints:
- websecure
routes:
- kind: Rule
match: Host(`toto.localhost`) && (PathRegexp(`^/((assets.*|locales.*))`) || Path(`/`))
services:
- kind: Service
name: whoami1
port: 80
- kind: Rule
match: Host(`toto.localhost`) && (!PathRegexp(`^/((assets.*|locales.*))`) && !Path(`/`))
middlewares:
- name: middleware-frontend-replacement-path
services:
- kind: Service
name: whoami2
port: 80
---
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: middleware-frontend-replacement-path
spec:
replacePath:
path: /
I replaced the PathPrefix
by PathRegexp
, and changed the PathPrefix('/')
by a strict Path('/')
because the it would match everything so it sounded weird (but maybe I'm wrong here).
Details
❯ curl -k https://toto.localhost:8443
Hostname: whoami1-7b6f7cbc7f-jw8zx
IP: 127.0.0.1
IP: ::1
IP: 10.42.0.13
IP: fe80::c848:baff:fe52:9201
RemoteAddr: 10.42.0.12:48320
GET / HTTP/1.1
Host: toto.localhost:8443
User-Agent: curl/8.4.0
Accept: */*
Accept-Encoding: gzip
X-Forwarded-For: 127.0.0.1
X-Forwarded-Host: toto.localhost:8443
X-Forwarded-Port: 8443
X-Forwarded-Proto: https
X-Forwarded-Server: traefik-564cdb4977-4sz4h
X-Real-Ip: 127.0.0.1
❯ curl -k https://toto.localhost:8443/assets/test.js
Hostname: whoami1-7b6f7cbc7f-jw8zx
IP: 127.0.0.1
IP: ::1
IP: 10.42.0.13
IP: fe80::c848:baff:fe52:9201
RemoteAddr: 10.42.0.12:48320
GET /assets/test.js HTTP/1.1
Host: toto.localhost:8443
User-Agent: curl/8.4.0
Accept: */*
Accept-Encoding: gzip
X-Forwarded-For: 127.0.0.1
X-Forwarded-Host: toto.localhost:8443
X-Forwarded-Port: 8443
X-Forwarded-Proto: https
X-Forwarded-Server: traefik-564cdb4977-4sz4h
X-Real-Ip: 127.0.0.1
❯ curl -k https://toto.localhost:8443/locales/test.js
Hostname: whoami1-7b6f7cbc7f-jw8zx
IP: 127.0.0.1
IP: ::1
IP: 10.42.0.13
IP: fe80::c848:baff:fe52:9201
RemoteAddr: 10.42.0.12:48320
GET /locales/test.js HTTP/1.1
Host: toto.localhost:8443
User-Agent: curl/8.4.0
Accept: */*
Accept-Encoding: gzip
X-Forwarded-For: 127.0.0.1
X-Forwarded-Host: toto.localhost:8443
X-Forwarded-Port: 8443
X-Forwarded-Proto: https
X-Forwarded-Server: traefik-564cdb4977-4sz4h
X-Real-Ip: 127.0.0.1
❯ curl -k https://toto.localhost:8443/list
Hostname: whoami2-5f74765f4-cxhrn
IP: 127.0.0.1
IP: ::1
IP: 10.42.0.14
IP: fe80::9460:5bff:fe70:f36f
RemoteAddr: 10.42.0.12:53922
GET / HTTP/1.1
Host: toto.localhost:8443
User-Agent: curl/8.4.0
Accept: */*
Accept-Encoding: gzip
X-Forwarded-For: 127.0.0.1
X-Forwarded-Host: toto.localhost:8443
X-Forwarded-Port: 8443
X-Forwarded-Proto: https
X-Forwarded-Server: traefik-564cdb4977-4sz4h
X-Real-Ip: 127.0.0.1
X-Replaced-Path: /list
It seems to work nicely with this configuration.
If you have any other issues with the rules, don't hesitate to check the migration guide.
If this works for you, I will close the issue.
Edit: I'm closing the issue, if you still have a problem with this subject, don't hesitate to comment and we will reopen it if needed.
from traefik.
@youkoulayley Just waking up for the day. I totally looked around to see if there was a new "matcher". Once I am in the office I will give it a try. :)
from traefik.
Related Issues (20)
- Run a modified plugin in local mode but failed HOT 1
- Ability to choose compression algorithms in k8s Middleware HOT 5
- Can not get Service Metrics HOT 4
- kernel TLS (kTLS) support HOT 2
- Documentation has mismatch between Encoded Certificate and Human Readable presentation HOT 2
- ability to disable http/3 on certain hosts HOT 3
- [K8s] Allow empty Services in Errors Middleware HOT 8
- Traefik not respecting file middleware
- Intermittent issues with URL redirection HOT 4
- Multiple IP Domain Name handling HOT 1
- IP format checking on `ingressendpoint.ip` HOT 1
- HTTP 500 response for request with invalid chunked body HOT 1
- Allow `service.serversscheme` annotation on a per-port basis HOT 4
- ACME for selfhost (selfhost.de) HOT 1
- Add documentation for using podman with quadlet files HOT 1
- invalid memory address or nil pointer dereference HOT 4
- Feature: Use EndpointSlices API "Serving" status HOT 3
- Make IngressRouteTCP more similar to IngressRoute HOT 3
- Gateway API TLSRoutes appear to be handled in invalid scenarios HOT 2
- OpenTelemetry metric name issues
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from traefik.