# Reselect rserver depending of the server response URL after a 302

**URL:** <https://community.a10networks.com/t/reselect-rserver-depending-of-the-server-response-url-after-a-302/377>\
**Category:** aFleX\
**Tags:** aflex, http, slb-adc\
**Created:** [February 23, 2016, 8:00am UTC](https://community.a10networks.com/t/reselect-rserver-depending-of-the-server-response-url-after-a-302/377 "2016-02-23T08:00:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BTIGS](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@BTIGS](https://community.a10networks.com/u/BTIGS)\
**Post date:** [February 23, 2016, 8:00am UTC](https://community.a10networks.com/t/reselect-rserver-depending-of-the-server-response-url-after-a-302/377/1 "2016-02-23T08:00:58Z")

</div>

Hello

We have a web server that is configured in a way that, if it detects an internal failure like in the DB, it returns a 302 code redirecting the request to a sorry page in a URL format

http:///error

I need to create an script or maybe a healthcheck that allows me to detect that response, and then reselect another rserver in the same service-group. The server can also returns code 302 for a “normal” redirect answer, so I must detect betweend both situations. The code should be like

when HTTP\_RESPONSE { set destino HTTP::host if { [HTTP::is\_redirect] } { if { [HTTP::host] contains “error” } { LB::reselect } } }

But of course LB::reselect is not available in HTTP\_RESPONSE event, and the line that searchs for “error” string in the URL response doesn’t seems to work. Does anyone have an enviroment like this? How can I force a “reselect” action depending on the server answer to a HTTP query? Thanks a lot.

PD. I also asked the customer to use another code for this situation so I could set the server to maintenance mode if I receive in a healthcheck but he doesn’t want that change…

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/a10_community/original/1X/bb9f186d33804d3044a0374e589f49fdf3be1328.png) [@system](https://community.a10networks.com/u/system)\
**Post date:** [February 23, 2016, 7:12pm UTC](https://community.a10networks.com/t/reselect-rserver-depending-of-the-server-response-url-after-a-302/377/2 "2016-02-23T19:12:01Z")

</div>

In this aFleX, the HTTP::retry command retries sending a client’s request to a service port that replies with an HTTP 302 status code.  
If the first server continues to redirect and to reply with a 302 status code after 3 retries, the LB::reselect command reassigns the client request to another server in the same service group.  
It causes SLB to select the next available member from the same service group used for the initial server selection.

aFlex;

when CLIENT\_ACCEPTED { set retry 0 set max\_retry 3 set reselect 0 } when LB\_SELECTED { if { $retry \> 0 } { LB::reselect incr reselect } } when HTTP\_RESPONSE { if { [HTTP::is\_redirect] } { if { $retry \< $max\_retry } { if { [HTTP::status] contains “302” } { incr retry } } } }

I Hope this helps.

---

<div class="post-metadata">

**Author:** ![BTIGS](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@BTIGS](https://community.a10networks.com/u/BTIGS)\
**Post date:** [February 24, 2016, 11:52am UTC](https://community.a10networks.com/t/reselect-rserver-depending-of-the-server-response-url-after-a-302/377/3 "2016-02-24T11:52:43Z")

</div>

Hi

Ok, thanks. I’ll try it and update if it works.  
Anyway I have a doubt about this script. There’s no way to tell the SLB not to select the same server a second time , isn’t it? I mean, if we only make it reselect another server of the pool, it could select the same server with the error over and over.

Again, thanks for your help.
