fabio icon indicating copy to clipboard operation
fabio copied to clipboard

Catch all redirect

Open magiconair opened this issue 6 years ago • 6 comments

This patch adds the option to redirect to the same host but maybe on a different path or scheme.

For this $host can be used on the target URL, e.g.

route add https-redirect / https://$host$path opts "redirect=301"

magiconair avatar Feb 26 '18 15:02 magiconair

Hmm, not sure whether this creates a redirect loop.

magiconair avatar Feb 26 '18 15:02 magiconair

If we interpret that https-redirect as only valid for originating http that should be redirected to https I think this works. Meaning that https-redirect will never match an incoming https request.

Otherwise we could keep the same http-redirect with the additional $host pseudo var and restrict on port in the rule something like...

route add http-redirect :80 https://$host$path opts "redirect=301"

aaronhurt avatar Feb 26 '18 15:02 aaronhurt

Sorry, just looked at the code ... there's not a new option it is just adding the pseudo var. So I think that you would get a redirect loop with a path / match but shouldn't with a port :80 match.

aaronhurt avatar Feb 26 '18 15:02 aaronhurt

Something like route add :80/ ... might be handy. Not sure if that fits well with the current syntax

magiconair avatar Feb 26 '18 15:02 magiconair

Agreed a host agnostic match with a port and path is exactly what you would want for this specific use case.

aaronhurt avatar Feb 26 '18 15:02 aaronhurt

How about https://github.com/fabiolb/fabio/pull/544 instead?

holtwilkins avatar Sep 04 '18 00:09 holtwilkins