Forum Discussion

knwminus2018_37's avatar
knwminus2018_37
Icon for Nimbostratus rankNimbostratus
Nov 29, 2018

Rewrite and set pool

I'm trying to rewrite a url and set a pool. The redirect works but it's not setting the pool information properly. Does anyone have an idea as to why this isn't working?

 

when HTTP_REQUEST { if { ( [string tolower [HTTP::uri]] starts_with "/xxx/xxx" ) } { HTTP::redirect "https://[HTTP::host][HTTP::uri]" pool azure-sharepoint-2016 } }

 

  • It's about flow.

    • The HTTP::redirect command issues an HTTP 302 redirect to the client - a 302 response with a Location header that says to go somewhere else.

    • The pool command is setting an inbound path.

    So basically, these two commands are flow-incompatible. One is sending traffic back to the client, and the other directing traffic inwards, which cannot happen at the same time. You're also redirecting to the same URL on HTTPS, which might indicate that HTTPS is listening on a separate VIP (that wouldn't see the pool command anyway).

    If I were to assume that any URI starting with "/xxx/xxx" needed to a) go to an HTTPS site listening on a separate VIP, and b) go to a specific pool, you'd need one iRule on each VIP:

    • HTTP VIP:

      when HTTP_REQUEST {
          if { ( [string tolower [HTTP::uri]] starts_with "/xxx/xxx" ) } {
              HTTP::redirect "https://[HTTP::host][HTTP::uri]"
          }
      }
      
    • HTTPS VIP:

      when HTTP_REQUEST {
          if { ( [string tolower [HTTP::uri]] starts_with "/xxx/xxx" ) } {
              pool azure-sharepoint-2016
          }
      }