# Force persistence to a server for testing

**URL:** <https://community.a10networks.com/t/force-persistence-to-a-server-for-testing/253>\
**Category:** aFleX\
**Created:** [February 4, 2014, 11:24am UTC](https://community.a10networks.com/t/force-persistence-to-a-server-for-testing/253 "2014-02-04T11:24:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mischa](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mischa](https://community.a10networks.com/u/mischa)\
**Post date:** [February 4, 2014, 11:24am UTC](https://community.a10networks.com/t/force-persistence-to-a-server-for-testing/253/1 "2014-02-04T11:24:44Z")

</div>

#################################################

# 

# Test specific server in pool

# (c) A10 Networks – MP

# v1 20140128

# 

#################################################

# 

# aFleX script that allows you to create easy

# persistence to a specific server in a pool.

# 

# To test: http:///test:

# To stop: http:///notest

# 

# For eample:

# [http://192.168.1.80/test:192.168.1.23](http://192.168.1.80/test:192.168.1.23)

# 

# Questions & comments welcome.

# mpeters AT a10networks DOT com

# 

#################################################  
when RULE\_INIT {  
set ::DEBUG 0  
set ::PORT 80  
set ::TABLE “nodetable”  
}  
when HTTP\_REQUEST {  
if { $::DEBUG == 1 } { log “URI: [HTTP::uri]” }  
if { [HTTP::uri] contains “test” } {  
set ACTION [getfield [HTTP::uri] “:” 1]  
set NODE [getfield [HTTP::uri] “:” 2]  
if { $::DEBUG == 1 } { log “ACTION: $ACTION; NODE: $NODE” }  
switch $ACTION {  
/test {  
table set $::TABLE [IP::client\_addr] $NODE indef indef  
if { $::DEBUG == 1 } { log “CREATED ENTRY FOR [IP::client\_addr] → $NODE:$::PORT” }  
HTTP::redirect /  
}  
/notest {  
table delete $::TABLE [IP::client\_addr]  
if { $::DEBUG == 1 } { log “ENTRY DELETED FOR [IP::client\_addr]” }  
HTTP::redirect /  
}  
}  
}  
set NODE [table lookup $::TABLE [IP::client\_addr]]  
if { $NODE != “” } {  
node $NODE $::PORT  
if { $::DEBUG == 1 } { log “ENTRY FOUND: [IP::client\_addr] → $NODE:$::PORT” }  
}  
}

---

<div class="post-metadata">

**Author:** ![andyo.kyiv.ua](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@andyo.kyiv.ua](https://community.a10networks.com/u/andyo.kyiv.ua)\
**Post date:** [June 6, 2014, 12:30pm UTC](https://community.a10networks.com/t/force-persistence-to-a-server-for-testing/253/2 "2014-06-06T12:30:44Z")

</div>

Hello Mischa,  
Thank U for useful script. Do I understand correctly that HTTP::redirect / just redirects browser to [http://192.168.1.80/](http://192.168.1.80/)?
