- 最新
- 投票最多
- 评论最多
Hi,
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:
https://docs.aws.amazon.com/elasticloadbalancing/latest/application/listener-update-rules.html
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!
-randy
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.
Hi,
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>
-randy
or operator will mean it still matches with user=jeff1.
Thanks anyway!
Edited by: mkonecny84 on Sep 24, 2019 5:42 PM
Hi,
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,
-randy
This suggestion works, but some web clients may add a space between the semicolon and the next cookie.
"a=1; user=jeff"
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.
Strange, this simple one also works as expected
Host is example.com
Http header cookie is *name=true*
相关内容
- AWS 官方已更新 6 年前
- AWS 官方已更新 2 年前
- AWS 官方已更新 2 年前
- AWS 官方已更新 2 年前