Example 8: Redirect Queries to the Queried Server 编辑
Example Inc. wants to redirect query requests to the appropriate server, as shown here.
<Request: GET /query.cgi?server=5HOST: www.example.com
<Redirect URL: <http://web-5.example.com/>
To implement this redirection, you would first create a rewrite action with the values in the following table.
Action Name | Type of Rewrite Action | Expression to choose target reference | String expression for replacement text |
---|---|---|---|
Action-Rewrite-Replace_Hostheader | REPLACE | HTTP.REQ.HEADER(“Host”).BEFORE_STR(“.example.com”) | “server-“ + HTTP.REQ.URL.QUERY.VALUE(“web”) |
You would then create a rewrite policy with the values in the following table.
Policy Name | Action Name | Undefined Action | Expression |
---|---|---|---|
Policy-Rewrite-Replace_Hostheader | Action-Rewrite-Replace_Hostheader | NOREWRITE | HTTP.REQ.HEADER("Host").EQ("www.example.com") |
Example commands:
> add rewrite action Action-Rewrite-Server_Mask REPLACE HTTP.RES.HEADER("Server") "\"Web Server 1.0\""
Done
> add rewrite policy-Rewrite-Server_Mask HTTP.RES.IS_VALID Action-Rewrite-Server_Mask NOREWRITE
Done
Finally, you would bind the rewrite policy, assigning it a priority of 900. Because this policy should be the last policy applied to a request that matches its criteria, you set the goto expression to END.
Incoming requests to any URL that begins with <http://www.example.com/query.cgi?server>=
are redirected to the server number in the query.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论