Skip to content

Redirect 301, 302, 308 #1009

Closed
Closed

Description

@beckend

Match URI, then redirect to another.

Activity

  1. FlorentinDUBOIS commented on Oct 25, 2023

    @FlorentinDUBOIS
    Collaborator

    Hello,
    Could give us more details about what you want to achieve and your need?

  2. beckend commented on Oct 25, 2023

    @beckend
    Author

    here is something from envoy, I hope this is clear

                    "route_config": {
                      "name": "local_route",
                      "virtual_hosts": [
                        {
                          "name": "all-international",
                          "domains": ["sang.international","*.sang.international"],
                          "routes": [
                            {
                              "match": {
                                "prefix": "/"
                              },
                              "redirect": {
                                "host_redirect": "sang.agency"
                              }
                            }
                          ]
                        }
                      ]
                    },
    
  3. Walker-00 commented on Jul 15, 2024

    @Walker-00

    @FlorentinDUBOIS I think it's something like matching subdomain request and route to the specific port or url, and I also needing that

  4. FlorentinDUBOIS commented on Oct 14, 2024

    @FlorentinDUBOIS
    Collaborator

    Sorry for the late response, I miss the notification. So, we already have implemented the wildcard matching pattern using or not path prefix, equals or regex. However, we do not have a redirect feature yet.

  5. FlorentinDUBOIS commented on Oct 14, 2024

    @FlorentinDUBOIS
    Collaborator

    @Wonshtrum is the redirect feature easy to implement?

  6. Walker-00 commented on Oct 15, 2024

    @Walker-00

    should implement that feature, waiting for it.

  7. Wonshtrum commented on Oct 18, 2024

    @Wonshtrum
    Member

    The redirection itself is quite straightforward, but I'm not quite sure about the integration with the tooling: command line, config.toml, protobuf messages...
    We should also decide what exactly are the capabilities of this feature. I don't know how it is done in other reverse proxies, but can we only change the authority? Should we be able to change the path? Is it a simple replacement or should we handle wildcards (*.domain.com -> *.domain2.com), if so what about regexes?

  8. Wonshtrum commented on Dec 11, 2024

    @Wonshtrum
    Member

    Hi @beckend, @Walker-00,
    I am currently working on a URL rewriting and redirection features and was wondering if a system like the one proposed in issue #1161 would meet your needs. Please let me know your thoughts!

  9. FlorentinDUBOIS commented on Apr 30, 2026

    @FlorentinDUBOIS
    Collaborator

    Partial-status update: 301 (RedirectPolicy::Permanent) and 401 (RedirectPolicy::Unauthorized) are implemented on main per-frontend, with optional rewrite_host / rewrite_path / rewrite_port shaping the Location URL and an optional redirect_template for a custom response body. Configuration shape:

    [[clusters.MyCluster.frontends]]
    address  = "0.0.0.0:80"
    hostname = "old.example.com"
    redirect        = "permanent"      # forward (default) | permanent | unauthorized
    redirect_scheme = "use-https"      # use-same (default) | use-http | use-https
    rewrite_host    = "new.example.com"
    rewrite_port    = 8443             # optional; falls back to cluster.https_redirect_port

    Documented under doc/configure.md (Frontend redirect, URL rewrite, and custom headers section) and exercised in e2e/src/tests/redirect_rewrite_auth_tests.rs.

    Still missing on main:

    • RedirectPolicy::Temporary → 302
    • A 308 variant (whether named RedirectPolicy::PermanentRedirect or as a distinct enum value)

    Both extensions touch the same surface: the RedirectPolicy enum in command/src/command.proto, the case-insensitive parser in command/src/config.rs, the dispatch arm in lib/src/protocol/mux/router.rs::route_from_request, and the 301 arm of the answer engine at lib/src/protocol/kawa_h1/answers.rs::HttpAnswers::template. Mostly mechanical — happy to take the contribution if anyone wants to pick it up. Leaving this open as the tracking issue for the 302 / 308 work.

  10. added a commit that references this issue on Apr 30, 2026
  11. added 3 commits that reference this issue on May 2, 2026
    4678023
    8af4b56
    dbbea65
  12. added this to the v2.0.0 milestone on May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions