Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: switch to traefik v3 #90

Merged
merged 3 commits into from
Nov 11, 2024
Merged

refactor: switch to traefik v3 #90

merged 3 commits into from
Nov 11, 2024

Conversation

sjinks
Copy link
Member

@sjinks sjinks commented Nov 2, 2024

No description provided.

@sjinks sjinks self-assigned this Nov 2, 2024
@sjinks
Copy link
Member Author

sjinks commented Nov 2, 2024

Should route to a different port if specified:

Failing tests (return 404 instead of 200):

curl -s -o /dev/null -I -w "%{http_code}" http://lets.combine.really.lndo.site/everything/for-real | grep 200
curl -s -o /dev/null -I -w "%{http_code}" http://lets.combine.things.lndo.site/everything/for-real | grep 200

Should handle sites in subdirectories:

Failing tests (404 instead of 200):

curl -s -o /dev/null -I -w "%{http_code}" http://lets.combine.really.lndo.site/everything/for-real | grep 200

@sjinks
Copy link
Member Author

sjinks commented Nov 2, 2024

proxy:
  web3:
    - "lets.combine.*.lndo.site:8080/everything/for-real"
    - "*.more.web3.lndo.site:8080"
    - web3.lndo.site:8080
    - web4.lndo.site:8080
    - hostname: web5.lndo.site
      port: 8080

@sjinks
Copy link
Member Author

sjinks commented Nov 2, 2024

  "traefik.http.routers.510d6d3d68c13189d4b27ff98c3606c77a802cd0-secured.entrypoints": "https",
  "traefik.http.routers.510d6d3d68c13189d4b27ff98c3606c77a802cd0-secured.middlewares": "510d6d3d68c13189d4b27ff98c3606c77a802cd0-lando,510d6d3d68c13189d4b27ff98c3606c77a802cd0-stripprefix",
  "traefik.http.routers.510d6d3d68c13189d4b27ff98c3606c77a802cd0-secured.rule": "HostRegexp(`lets.combine.{wildcard:[a-z0-9-]+}.lndo.site`) && PathPrefix(`/everything/for-real`)",
  "traefik.http.routers.510d6d3d68c13189d4b27ff98c3606c77a802cd0-secured.service": "510d6d3d68c13189d4b27ff98c3606c77a802cd0-secured-service",
  "traefik.http.routers.510d6d3d68c13189d4b27ff98c3606c77a802cd0-secured.tls": "true",
  "traefik.http.routers.510d6d3d68c13189d4b27ff98c3606c77a802cd0.entrypoints": "http",
  "traefik.http.routers.510d6d3d68c13189d4b27ff98c3606c77a802cd0.middlewares": "510d6d3d68c13189d4b27ff98c3606c77a802cd0-lando,510d6d3d68c13189d4b27ff98c3606c77a802cd0-stripprefix",
  "traefik.http.routers.510d6d3d68c13189d4b27ff98c3606c77a802cd0.rule": "HostRegexp(`lets.combine.{wildcard:[a-z0-9-]+}.lndo.site`) && PathPrefix(`/everything/for-real`)",
  "traefik.http.routers.510d6d3d68c13189d4b27ff98c3606c77a802cd0.service": "510d6d3d68c13189d4b27ff98c3606c77a802cd0-service",

@sjinks
Copy link
Member Author

sjinks commented Nov 2, 2024

Traefik 3 does not seem to support named regexps.

https://doc.traefik.io/traefik/v2.11/routing/routers/#rule
https://doc.traefik.io/traefik/routing/routers/#rule

-HostRegexp(`lets.combine.{wildcard:[a-z0-9-]+}.lndo.site`)
+HostRegexp(`lets.combine.[a-z0-9-]+.lndo.site`)

@sjinks
Copy link
Member Author

sjinks commented Nov 2, 2024

diff --git a/plugins/lando-proxy/lib/utils.js b/plugins/lando-proxy/lib/utils.js
index 102f115e..dca72e25 100644
--- a/plugins/lando-proxy/lib/utils.js
+++ b/plugins/lando-proxy/lib/utils.js
@@ -54,7 +54,7 @@ exports.getProxyRunner = (project, files) => ({
  */
 exports.getRule = rule => {
   // Start with the rule we can assume
-  const hostRegex = rule.host.replace(new RegExp('\\*', 'g'), '{wildcard:[a-z0-9-]+}');
+  const hostRegex = rule.host.replace(new RegExp('\\*', 'g'), '[a-z0-9-]+');
   const rules = [`HostRegexp(\`${hostRegex}\`)`];
   // Add in the path prefix if we can
   if (rule.pathname.length > 1) rules.push(`PathPrefix(\`${rule.pathname}\`)`);

@sjinks
Copy link
Member Author

sjinks commented Nov 11, 2024

809e8f9 will break tests because the image is not yet in the ghcr.io container registry. Rerun the failed job once Automattic/vip-container-images#955 is merged and the images are built.

@sjinks sjinks merged commit 6ca2668 into main Nov 11, 2024
58 checks passed
@sjinks sjinks deleted the traefik3 branch November 11, 2024 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants