Forum Discussion
load balance using http methods
We have 1 read/write node and two Read-only nodes, so we want all the Get http requests to be distributed equally in them and all other requests like POST, Patch, Delete to be forwarded to read/write node
Example :-
Node1 : R/W " it will receives Get , Post,Patch,Delete "
Node2 : Read-only "it will receives Get Requests only "
Node3 : Read-only "it will receives Get Requests only "
Thank you in advance
- MaximPCirrus
Hi, Ahmed.
You need to use an Irule, something like this
when HTTP_REQUEST {
if { ([string toupper [HTTP::method]] equals "POST" ) or ([string toupper [HTTP::method]] equals "PATCH" ) or ([string toupper [HTTP::method]] equals "DELETE" ) } {
node 1.1.1.1 443
}
elseif { [string toupper [HTTP::method]] equals "GET" } {
pool POOL-name
}
else {
HTTP::respond 405 content {
<html>
<head><title>HTTP Request denied</title></head>
<body>Your HTTP requests are being throttled.</body>
</html>
}
}
}
- Ahmed_MohsenNimbostratus
Thank you for your reply
Kindly when i deploy this iRule it shown me an error
- MaximPCirrus
Yep, there were some extra brackets. I edited previos message, try again.
- Ahmed_MohsenNimbostratus
Thank you i will try it :)
- Ahmed_MohsenNimbostratus
Salam bro ,
I am trying to test the script in testing environment but it shown this error to me :-
Thank you in advance
- ka1021Altostratus
Hello Ahmed,
i guess there are some extra spaces between "}" and "elseif".
when HTTP_REQUEST {
if { ([string toupper [HTTP::method]] equals "POST" ) or ([string toupper [HTTP::method]] equals "PATCH" ) or ([string toupper [HTTP::method]] equals "DELETE" ) } {
node XXXXXXX XX
} elseif { [string toupper [HTTP::method]] equals "GET" } {
pool XXXXXX
} else {
HTTP::respond 405 content {
<html>
<head><title>HTTP Request denied</title></head>
<body>Your HTTP requests are being throttled.</body>
</html>
}
}
}
- ka1021Altostratus
☝️ Try this
- Ahmed_MohsenNimbostratus
Thank you it's accepted now ,
before we start the testing in virtual server setting i will need to configure http profile or http-explicit ?
- ka1021Altostratus
Should work with http profile.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com