Gen AI in Business - Global Trends Report 2024.pdf
Nine Ways to Use Network-Side Scripting
1. Nine ways to use network-side scripting to architect more scalable, secure, and fast applications Presented by: F5 Networks
2. Network-side scripting executes discrete application functions on the application delivery platform. Network Administrator Application Developer Application delivery platform Application
3. Cookie Encryption 1 2 3 4 1 2 3 4 Web request received by BIG-IP application delivery platform. Encrypted cookie is decrypted and reinserted into the HTTP header Request sent to appropriate web application server where processing occurs normally Response is sent from web application server back to BIG-IP application delivery platform BIG-IP application delivery platform receives response, encrypts appropriate cookie and reinserts into the HTTP header and returns to the browser
4. Cookie Encryption when RULE_INIT { # Generate Unique Key set ::key [AES::key] } when HTTP_RESPONSE { set decrypted [HTTP::cookie "MyCookie"] if { "" ne $decrypted } { # remove the original cookie, encrypt it, and then insert the encrypted value HTTP::cookie remove "MyCookie" set encrypted [b64encode [AES::encrypt $::key $decrypted]] HTTP::cookie insert name "MyCookie" value $encrypted } } when HTTP_REQUEST { set encrypted [HTTP::cookie "MyCookie"] if { "" ne $encrypted } { # remove encrypted cookie, decrypt it, and insert the decrypted value. HTTP::cookie remove "MyCookie" set decrypted [AES::decrypt $::key [b64decode $encrypted]] HTTP::cookie insert name "MyCookie" value $decrypted } }
5. Session Persistence 1 2 3 4 1 2 3 4 A first web request received by BIG-IP application delivery platform. BIG-IP chooses a server a forwards the request When the request returns BIG-IP notes the specified session id (JSESSIONID, PHPSESSIONID, etc..) in its session table along with the server and returns the request to the browser A second request is received. The BIG-IP application delivery platform extracts the session id cookie and determines to which server the request should be sent based on its session table Request is sent to the same server, preserving session state in the web application
6.
7. URI Rewrite 1 2 1 2 Web request received by BIG-IP application delivery platform. An iRule recognizes the URI and executes code to change the URI Request sent to appropriate web application server where processing occurs normally
8.
9. Application Switching 1 2 3 4 1 2 3 4 Web request received by BIG-IP application delivery platform. BIG-IP examines the request and determines to which server it should be sent. Request sent to appropriate web application server where processing occurs normally Another request is received by BIG-IP application delivery platform. BIG-IP examines the request and determines to which server it should be sent Request sent to appropriate web application server where processing occurs normally GET /image.jpg GET /mypage.html
10.
11. Exception Handling 1 2 3 4 1 2 3 4 Web request received by BIG-IP application delivery platform. BIG-IP examines the request and determines to which server it should be sent. Request sent to appropriate web application server where processing occurs normally BIG-IP recognizes that the response contains an error indicated by a 404 status or a 200 status with content containing an exception (a stack trace, for example) BIG-IP retries the request on another server and when it comes back valid returns it to the browser
12.
13. Data Scrubbing 1 2 3 4 1 2 3 4 Web request received by BIG-IP application delivery platform. BIG-IP examines the request and determines to which server it should be sent. Request sent to appropriate web application server where processing occurs normally BIG-IP recognizes that the response contains a credit card number. The iRule “scrubs” the number by replacing all digits in the credit card number with an X BIG-IP returns the response with the “clean” data to the browser
14.
15. when HTTP_RESPONSE_DATA { # Find ALL the possible credit card numbers in one pass set card_indices [regexp -all -inline -indices {(?:3[4|7]{2})(?:[ ,-]?(?:{5}(?:{1})?)){2}|(?:4{3})(?:[ ,-]?(?:{4})){3}|(?:5[1-5]{2})(?:[ ,-]?(?:{4})){3}|(?:6011)(?:[ ,-]?(?:{4})){3}} [HTTP::payload]] foreach card_idx $card_indices { set card_start [lindex $card_idx 0] set card_end [lindex $card_idx 1] set card_len [expr {$card_end - $card_start + 1}] set card_number [string range [HTTP::payload] $card_start $card_end] # Remove dash or space if they exist and count the occurences in variable cutouts. set cutouts [regsub -all {[- ]} $card_number "" card_number] # Adjsut card_len variable but keep it for later use. set new_card_len [expr {$card_len - $cutouts}] set double [expr {$new_card_len & 1}] set chksum 0 set isCard invalid # Calculate MOD10 for { set i 0 } { $i < $new_card_len } { incr i } { set c [string index $card_number $i] if {($i & 1) == $double} { if {[incr c $c] >= 10} {incr c -9} } incr chksum $c } # Determine Card Type switch [string index $card_number 0] { 3 { set type AmericanExpress } 4 { set type Visa } 5 { set type MasterCard } 6 { set type Discover } default { set type Unknown } } # If valid card number, then mask out numbers with X's if { ($chksum % 10) == 0 } { set isCard valid HTTP::payload replace $card_start $card_len [string repeat "X" $card_len] } # Log Results log local0. "Found $isCard $type CC# $card_number" } }
16. Intelligent Compression 1 2 3 1 2 3 A first web request received by BIG-IP application delivery platform. BIG-IP checks the client’s bandwidth and chooses a server a forwards the request The request is handled normally by the web application server/web server and returned to BIG-IP BIG-IP takes into consideration the bandwidth available and the type of content and determines whether it will be a performance plus or negative to apply compression, then acts on that decision and returns the response to the client
17.
18. LDAP Connection Proxy 1 2 3 4 1 2 3 4 Request received by BIG-IP application delivery platform. BIG-IP examines the request by looking at the TCP payload and finds the string that represents the unbind command. BIG-IP releases the client binding to the LDAP server BIG-IP keeps the TCP connection to the LDAP server open for reuse The original unbind command is discarded and LDAP server’s overhead reduced
20. Homerize your errors 1 2 3 4 1 2 3 4 Web request received by BIG-IP application delivery platform. BIG-IP examines the request and determines to which server it should be sent. Request sent to appropriate web application server where processing occurs normally BIG-IP recognizes that the response is a 404 not found. The iRule responds by rewriting the content and p lacing an embedded wav file of homer saying “Doh!” in the response. BIG-IP returns the response with the “clean” data to the browser
21. Homerize Your Errors when HTTP_REQUEST { # Check for sensitive documents. set check_content 1 # Don't allow data to be chunked. if {[HTTP::version] == "1.1"} { if {[HTTP::header is_keepalive]} { # Adjust the Connection header. HTTP::header replace "Connection" "Keep-Alive" } HTTP::version "1.0" } } when HTTP_RESPONSE { #check to see if it is a 404 if { [HTTP::status] == "404" } { if {$check_content == 1} { set replace_now 1 # Calculate the amount to collect set content_length 0 if {[HTTP::header exists "Content-Length"]} { set content_length [HTTP::header "Content-Length"] } # If the header is missing, use a sufficiently large number if {$content_length == 0} { set content_length 4294967295 } HTTP::collect $content_length } } } when HTTP_RESPONSE_DATA { set payload [HTTP::payload [HTTP::payload length]] set fun_payload "<html><body><EMBED src =amp;quot;http://www.fortunecity.com/lavendar/poitier/135/nevertry.wavamp;quot; width=amp;quot;144amp;quot; height=amp;quot;60amp;quot; autostart=amp;quot;trueamp;quot; loop=amp;quot;trueamp;quot; hidden=amp;quot;trueamp;quot;>404 error Page not found</body></html>" #check to see if it should replace the content due to a 404 if {$replace_now == 1} { # Replace the content if there was any matches HTTP::payload replace 0 [HTTP::payload length] $fun_payload } }