Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- when HTTP_REQUEST {
- # Assume there is no redirections/rewrites
- set isRedirected false
- # Variable used by the rand() function. Varies from 0 to 1. Examples : 0.05 is 5%, 0.50 is 50%.
- set percentage 0
- # This variable will be set to a Pool name and sent to the client as a cookie (yp_mobile_backend)
- set pool_selected ""
- # Variable used to trigger redirections/rewrites needed when requests are sent to ResponsiveWeb only.
- set toResponsiveWeb false
- # Get yp_mobile_responsive1 cookie from browser. Use it if it matches one of the existing pools :
- # CANPAGES_WEB_POOL_01 = Responsive web pool
- switch [HTTP::cookie yp_mobile_responsive1] {
- CANPAGES_WEB_POOL_01 {
- pool [HTTP::cookie yp_mobile_responsive1]
- set toResponsiveWeb true
- }
- default {
- # If no cookie exists, use the rand() function to calculate a number from 0 to 1.
- # If the number is less than 0.01 (i.e. 1%), proxy the request to the Responsive Web pool.
- # Else, proxy the request to the Amazon Mobile Web pool.
- # Add the name of the pool to the $selected variable so we can later send the cookie and its value in the response.
- if { rand() < $percentage } {
- if {[HTTP::host] equals "mobile.canpages.ca" } {
- [HTTP::header replace "Host" "canpages.ca"]
- }
- pool CANPAGES_WEB_POOL_01
- set toResponsiveWeb true
- set pool_selected CANPAGES_WEB_POOL_01
- } else {
- if {[[HTTP::host] equals "mobile.canpages.ca"] } {
- HTTP::respond 301 Location http://mobile.canpages.ca[HTTP::uri]
- pool CANPAGES_EXTERNAL_POOL_01
- set pool_selected CANPAGES_EXTERNAL_POOL_01
- set isRedirected true
- }
- }
- }
- }
- }
- when HTTP_RESPONSE {
- # If a pool name was added to the $selected variable, send that value inside the yp_mobile_responsive1 cookie
- if {$pool_selected ne ""}{
- HTTP::cookie insert name yp_mobile_responsive1 value $selected path "/"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement