I have verified this works on an Application Load Balancer.
The Http Header rules allow wild cards. If the KEY value is "cookie", the VALUE should be changed:
from: user=jeff to: *user=jeff* This will allow your cookie to have values, such as: dog=cat;user=jeff;JSESSIONID=sdf12321 and this will still route to the same location when the cookie was just set to user=jeff.
Here is the link that describes the comparison string supporting the wildcards:
To add an HTTP header condition, choose Add condition, Http header. Type the name of the header and add one or more comparison strings. To save the condition, choose the checkmark icon. The maximum size of each header name is 40 characters, the header name is case-insensitive, and wildcards are not supported. The maximum size of each comparison string is 128 characters and the following wildcard characters are supported: * and ?. The comparison is case-insensitive.
Hope this helps!
HI Randy, thanks for your help.
This looks useful, but it would also match with user=jeff1.
Ideally AWS supports key/value cookie parsing, but I might still be able to use this.
To fulfill that specific requirement, you could have the rule ID set up as follows:
IF (all match) Http header... cookie is user=jeff or user=jeff; or user=jeff<space>
or operator will mean it still matches with user=jeff1.
Edited by: mkonecny84 on Sep 24, 2019 5:42 PM
One last try, and I think I covered all of the test cases and I have just verified using the ALB.
I created an Application Load Balancer and create the following rules:
IF (all match) Http header... cookie is user=jeff or user=jeff;* or *;user=jeff or *;user=jeff;* For the THEN 1. Return fixed response... Response code: 200 Content-type: text/plain Response body: "Yay it worked"
I then launched Postman and tried different values for the cookies
Here are the successful 200 use cases: user=jeff - 200 user=jeff;JESSIONID=sdf12321 - 200 dog=cat;user=jeff;bird=mouse - 200 Here are the failed 503 use cases: user=jeff1 - 503 abuser=jeff - 503 cat=mouse;user=jeff bird=mouse - 503 (missing semicolon)
Hope this helps,
This suggestion works, but some web clients may add a space between the semicolon and the next cookie.
So the wildcard rules should be something like this, since you can only have a max of 5 rules:
IF (all match) Http header... cookie is *user=jeff;* or user=jeff;* or *user=jeff; or *user=jeff;*
There has to be a simpler way to accomplish this.
API Gateway Dynamic routingAccepted Answerasked 2 years ago
Private DNS name for cross-account request to application load balancer routing via PrivateLinkAccepted Answerasked 5 months ago
NLB support for TLS passthrough on EKS based on URI pathsAccepted AnswerMODERATORasked 2 years ago
Application Load Balancer & AZ routingAccepted Answerasked a year ago
Amazon Connect Queue based routing question.Accepted Answerasked 5 months ago
Using a single Elastic IP and routing on FQDN with UDP requestsasked 8 months ago
Cookie based routing for Application Load Balancerasked 3 years ago
Cookie based routing on CloudFrontasked 5 months ago
Routing based on Cloudwatch metrics/alarmsasked 5 months ago
How do I get trigger broker topic's routing key on lambda functionasked 6 months ago