Score:0

AWS Application Load Balancer: Re-routing requests to non-approved paths

va flag

I have a use case where I would like all requests to start with a prefix like:

https://WHATEVER/pfx

For example https://WHATEVER/pfx/a and https://WHATEVER/pfx/b/c/d

But I wish to prevent https://WHATEVER/somewhere_else and similar requests that do not include the prefix (pfx). In preventing this, I'd like to simply redirect all such requests to https://WHATEVER/pfx (home page)

Is this possible with AWS ALB?

Thanks in advance!

Score:0
af flag

Yes. You would create a rule that forwards traffic that matches the pattern "https://whatever/pfx/*" and probably also "https://whatever/pfx" to your target group. The second pattern can be included in the same rule and is intended to match the target without the trailing slash.

Then you would create another rule below that rule with the pattern "http://whatever/*" with an action of redirect and a target of "https://whatever/pfx"

Finally you need to figure out what to do with the default. It sounds like redirecting to "https://whatever/pfx" may be the behavior you want. So you may be able to omit the second rule and just configure the default behavior.

You may also want to consider a rule that redirects http://whatever/* to https://whatever/ if users may hit your site without "s" in https.

CharlieBucket avatar
va flag
Thanks very much. I'll give it a try, but two questions: (1) I assume you meant [... below that rule with the pattern "https ] not "http and (2) I want to make sure I understand your point about "the default" -- what do you mean by default? Thx!
CharlieBucket avatar
va flag
Actually, no need to reply -- I realized you meant "/" as default (at least I'm guessing you did). In any case, works just great, the rule precedence thing accomplishes the main goal!
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.