Forum Discussion

S0S0_251956's avatar
S0S0_251956
Icon for Nimbostratus rankNimbostratus
Oct 18, 2017

URI Redirection with URI Allow

Hello I'm configuring LTM to redirect traffic for "/" to /frontend-web/app/auth.html and also I want to allow only URIs that contain /frontend-web/app/ and /frontend-web/api/ for that website. I configured data group and using below iRule, but redirection part is not working, when I'm accessing https://site.com connection is reset. Blocking part works fine. Can you help me with that ?

   when HTTP_REQUEST {
 if { [string tolower [HTTP::uri]] equals "/" } {
        HTTP::redirect "https://[HTTP::host]/frontend-web/app/auth.html"
    } 
 if { [ class match [string tolower [HTTP::uri]] contains uri_allow ] } {
  return }
 else {HTTP::respond 200 content "URL Blocked" } 
 }

1 Reply

  • P_K's avatar
    P_K
    Icon for Altostratus rankAltostratus

    I would think probably your block statement is matching the request and getting a reset.

     

    try adding some logging to the irule and see if it is matching the redirect or block statment. If your data group is properly done, then try below irule and see if that works someway..

     

    when HTTP_REQUEST {

     

    if { [string tolower [HTTP::uri]] equals "/" } {

     

    HTTP::redirect "https://[HTTP::host]/frontend-web/app/auth.html"

     

    log local0. "redirect matched [HTTP::uri]"

     

    }

     

    elseif { [ class match [string tolower [HTTP::uri]] contains uri_allow ] } {

     

    log local0. "datagroup matched [HTTP::uri].. blocking url"

     

    return

     

    }