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

Host+Path+Regex integrated redirect rule #1449

Open
alvaro-qwantec opened this issue Jun 16, 2020 · 2 comments
Open

Host+Path+Regex integrated redirect rule #1449

alvaro-qwantec opened this issue Jun 16, 2020 · 2 comments

Comments

@alvaro-qwantec
Copy link

Is your feature request related to a problem?
Yes, recently I started to use "kube-ingress-aws-controller" in my cluster k8s. A while ago I was using a Nginx server and I used the next redirect rule with success:

server {
    listen 80;
    listen 443 http2 ssl;
    server_name ~^(?<subdomain>\w+)\.example\.com$;
    location / {
        return 301 https://example.com/app/$subdomain;
    }
}

Is like a combination between modRequestHeader with modPath and Regex, and involves the entire request URL.

My question is, How can I do the same thing with Skipper annotations in my Ingress yaml?

Describe the solution you would like
option A) with an environment or context variable and using modRequestHeader and modPath:
modRequestHeader("Host", "^(?<company_id>\w+).example.com$", "example.com") -> modPath("/", "/app/$company_id")

option B) with an environment or context variable and using modRequestHeader and redirectTo:
modRequestHeader("Host", "^(?<company_id>\w+).example.com$", "example.com") -> redirectTo(301, "/app/$company_id")

option C) with a new function like modURL:
modURL("^(?<company_id>\w+).example.com$", "example.com/app/$company_id")

Describe alternatives you've considered (optional)
I don't have others, only the three that I wrote before.

Additional context (optional)
Nothing more.

Would you like to work on it?
No

@szuecs
Copy link
Member

szuecs commented Jun 25, 2020

Thanks for the idea and options provided, I think it's a valid enhancement request.
We will likely need some time to do it.
There are some more use cases for templating with variables, it's great to have some use cases provided.

Somehow also related to #1444
Cc @AlexanderYastrebov

@AlexanderYastrebov
Copy link
Member

It is possible with lua scripting:

all: Host(/^\w+\.example\.com$/) 
-> lua("
function request(ctx, params)
    local subdomain = ctx.request.host:gsub('%.example%.com', '')
    ctx.serve({
        status_code=301,
        header={
            location='https://example.com/app/' .. subdomain,
        },
    })
end
") -> <shunt>;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants