[READ-ONLY] Mirror of https://github.com/FoxxMD/blog. blog.foxxmd.dev
0

Configure Feed

Select the types of activity you want to include in your feed.

feat(rybbit): Reorganize route rule to use Method and PathRegexp

FoxxMD (Oct 17, 2025, 4:50 PM UTC) fa8c98b0 0ba05950

+10 -3
+10 -3
_posts/2025-08-06-rybbit-traefik-private-dashboard.md
··· 179 179 180 180 The key with this route is that we only want [*specific paths*](https://doc.traefik.io/traefik/routing/routers/#path-pathprefix-and-pathregexp) to be accessible when Rybbit is accessed from our **external** domain. These routes are: 181 181 182 + GET 183 + 182 184 * `/api/script.js` 183 185 * `/api/replay.js` 186 + * `/api/site/[number]/tracking-config` 187 + 188 + POST/OPTIONS 189 + 184 190 * `/api/track` 185 191 * `/api/session-replay/record` 186 192 187 - We will use Traefik [Path and PathPrefix](https://doc.traefik.io/traefik/routing/routers/#path-pathprefix-and-pathregexp) rules with a [Host](https://doc.traefik.io/traefik/routing/routers/#host-and-hostregexp) rule to achieve this restriction. Additionally, these routes only need to be accessible to rybbit's `backend` service. 193 + 194 + We will use Traefik [Path, PathPrefix, and PathRegexp](https://doc.traefik.io/traefik/routing/routers/#path-pathprefix-and-pathregexp) rules with a [Host](https://doc.traefik.io/traefik/routing/routers/#host-and-hostregexp) rule and [Method](https://doc.traefik.io/traefik/routing/routers/#method) rule to achieve this restriction. Additionally, these routes only need to be accessible to rybbit's `backend` service. 188 195 189 196 Modify the `labels` for `backend` service from your Rybbit compose file, adding these: 190 197 191 198 ```yaml 192 199 - "traefik.http.services.rybbit-ext.loadbalancer.server.port=3001" 193 - - "traefik.http.routers.rybbit-ext.rule=Host(`rybbit.myExtDomain.com`) && (Path(`/api/script.js`) || Path(`/api/replay.js`) || Path(`/api/track`) || PathPrefix(`/api/session-replay/record`) || (PathPrefix(`/api/site`) && PathRegexp(`tracking-config`)))" 200 + - "traefik.http.routers.rybbit-ext.rule=Host(`rybbit.myExtDomain.com`) && ((Method(`GET`) && (Path(`/api/script.js`) || Path(`/api/replay.js`) || PathRegexp(`^/api/site/[0-9]+/tracking-config`))) || ((Method(`POST`) || Method(`OPTIONS`)) && (Path(`/api/track`) || PathPrefix(`/api/session-replay/record`))))" 194 201 - "traefik.http.routers.rybbit-ext.service=rybbit-ext" 195 202 ``` 196 203 {: file="compose.yaml"} ··· 210 217 rybbit-ext: 211 218 #entryPoints: # may need to specify this 212 219 # - "websecure" 213 - rule: "Host(`rybbit.myExtDomain.com`) && (Path(`/api/script.js`) || Path(`/api/replay.js`) || Path(`/api/track`) || PathPrefix(`/api/session-replay/record`) || (PathPrefix(`/api/site`) && PathRegexp(`tracking-config`)))" 220 + rule: "Host(`rybbit.myExtDomain.com`) && ((Method(`GET`) && (Path(`/api/script.js`) || Path(`/api/replay.js`) || PathRegexp(`^/api/site/[0-9]+/tracking-config`))) || ((Method(`POST`) || Method(`OPTIONS`)) && (Path(`/api/track`) || PathPrefix(`/api/session-replay/record`))))" 214 221 service: rybbit-ext 215 222 216 223 services: