2

I'm trying to setup a route do a basic 301 redirect with the added benefit of supporting both HTTP and HTTPS requests. Expected results would be that requests to http://subdom.domain.org or https://subdom.domain.org would receive a 301 and be forwarded to https://othersub.domain.org/route. Actual results is that https://subdom.domain.org 301's as expected, but http://subdom.domain.org 404's. With the config, you can see I've tried doing both an elevate to HTTPS with the hopes that the rule might be caught there, but with the way the middleware is configured, I would expect it would work in either scenario.

Here's my current config:

http:
  routers:
    subdom.domain.org:
      entryPoints:
        - web
        - web-secure
      middlewares:
        - https-redirect # I've tried with this on and off
        - sudbdom-redirect 
      service: dummy
      rule: Host(`subdom.domain.org`)
      tls: 
        certResolver: letsEncryptResolver  

  middlewares:
    https-redirect:
      redirectScheme:
        scheme: https
    subdom-redirect:
      redirectRegex:
        regex: ".*"
        replacement: "https://othersub.domain.org/route"
        permanent: true

  services:
    dummy:
      loadBalancer:
        servers:
        - url: localhost

I was originally having trouble matching specific regex patterns for the redirect, but in realizing I didn't really need to scope the pattern at all given that I'm applying it per route, a wildcard match seems to work quite well there. Any thoughts or suggestions are appreciated. Thanks!

0 Answers0