Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. when HTTP_REQUEST {
  2.  
  3. # Assume there is no redirections/rewrites
  4.  
  5. set isRedirected false
  6.  
  7. # Variable used by the rand() function. Varies from 0 to 1. Examples : 0.05 is 5%, 0.50 is 50%.
  8.  
  9. set percentage 0
  10.  
  11. # This variable will be set to a Pool name and sent to the client as a cookie (yp_mobile_backend)
  12.  
  13. set pool_selected ""
  14.  
  15. # Variable used to trigger redirections/rewrites needed when requests are sent to ResponsiveWeb only.
  16.  
  17. set toResponsiveWeb false
  18.  
  19. # Get yp_mobile_responsive1 cookie from browser. Use it if it matches one of the existing pools :
  20.  
  21. # CANPAGES_WEB_POOL_01 = Responsive web pool
  22.  
  23. switch [HTTP::cookie yp_mobile_responsive1] {
  24.  
  25. CANPAGES_WEB_POOL_01 {
  26.  
  27. pool [HTTP::cookie yp_mobile_responsive1]
  28.  
  29. set toResponsiveWeb true
  30.  
  31. }
  32.  
  33. default {
  34.  
  35. # If no cookie exists, use the rand() function to calculate a number from 0 to 1.
  36.  
  37. # If the number is less than 0.01 (i.e. 1%), proxy the request to the Responsive Web pool.
  38.  
  39. # Else, proxy the request to the Amazon Mobile Web pool.
  40.  
  41. # Add the name of the pool to the $selected variable so we can later send the cookie and its value in the response.
  42.  
  43. if { rand() < $percentage } {
  44.  
  45. if {[HTTP::host] equals "mobile.canpages.ca" } {
  46. [HTTP::header replace "Host" "canpages.ca"]
  47. }
  48.  
  49. pool CANPAGES_WEB_POOL_01
  50.  
  51. set toResponsiveWeb true
  52.  
  53. set pool_selected CANPAGES_WEB_POOL_01
  54.  
  55. } else {
  56.  
  57. if {[[HTTP::host] equals "mobile.canpages.ca"] } {
  58.  
  59. HTTP::respond 301 Location http://mobile.canpages.ca[HTTP::uri]
  60.  
  61. pool CANPAGES_EXTERNAL_POOL_01
  62.  
  63. set pool_selected CANPAGES_EXTERNAL_POOL_01
  64.  
  65. set isRedirected true
  66.  
  67. }
  68.  
  69. }
  70.  
  71. }
  72.  
  73. }
  74.  
  75.  
  76. }
  77. when HTTP_RESPONSE {
  78.  
  79. # If a pool name was added to the $selected variable, send that value inside the yp_mobile_responsive1 cookie
  80.  
  81. if {$pool_selected ne ""}{
  82.  
  83. HTTP::cookie insert name yp_mobile_responsive1 value $selected path "/"
  84.  
  85. }
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement