I can't get this Irule to work

Hi Guy’s,

I’m trying to get this Irule to work, but I’m having some problems;

when HTTP_REQUEST {
       if { [HTTP::host] eq "dcc.dorsetforyou.com" and [HTTP::uri] ends_with "/Importer" } {
          HTTP::header replace Host "vmcrglassfish01.dorsetcc.local:18181"
          HTTP::uri "/Importer/"

         }
        if { [HTTP::host] eq "dcc.dorsetforyou.com" and [HTTP::uri] ends_with "/travelclaims" } {
              HTTP::header replace Host "vmcrglassfish01.dorsetcc.local:18181"
    }
        elseif { [HTTP::host] eq "dcc.dorsetforyou.com" } {
              HTTP::redirect "https://dorsetforyou.com"
    }
}

Any idrea ?

Hi Paul,

Just changing the value in the HTTP::header on the request will not affect the routing of the request. I can see what you are trying to do, so I would suggest putting the server that you are trying to direct traffic to in a pool then making your URI modifications if necessary and then directing traffic to the pool (the LTM will take care of the rest).

Something like this:

when HTTP_REQUEST {
 if { [string tolower [HTTP::host]] equals "dcc.dorsetforyou.com" } {
        switch -glob [string tolower [HTTP::uri]] {
         "/importer" { pool vmcrglassfish.pool }
         "travelclaims" {
                HTTP::uri "/SAPTECS/"
               pool vmcrglassfish.pool
         }
           "/" {
               HTTP::redirect "https://dorsetforyou.com"
           }
       }
   }
}

NOTE: You do not have to use switch statements (I like them because they are easier to follow and easier to add to if you know you are going to be doing a lot of manipulation on a given Virtual Server).

Hope this helps.

Hi Paul,

Just changing the value in the HTTP::header on the request will not affect the routing of the request. I can see what you are trying to do, so I would suggest putting the server that you are trying to direct traffic to in a pool then making your URI modifications if necessary and then directing traffic to the pool (the LTM will take care of the rest).

Something like this:

when HTTP_REQUEST {
 if { [string tolower [HTTP::host]] equals "dcc.dorsetforyou.com" } {
        switch -glob [string tolower [HTTP::uri]] {
         "/importer" { pool vmcrglassfish.pool }
         "travelclaims" {
                HTTP::uri "/SAPTECS/"
               pool vmcrglassfish.pool
         }
           "/" {
               HTTP::redirect "https://dorsetforyou.com"
           }
       }
   }
}

NOTE: You do not have to use switch statements (I like them because they are easier to follow and easier to add to if you know you are going to be doing a lot of manipulation on a given Virtual Server).

Hope this helps.

it depends on the application. For apps like DNN, it does actually route internally based on host header, so as long as IIS is configured correctly, you can send all requests to back end servers that can then hand to the correct portal by header. That said, based on the OP comments, I think your solution is inline with the ask.

it depends on the application. For apps like DNN, it does actually route internally based on host header, so as long as IIS is configured correctly, you can send all requests to back end servers that can then hand to the correct portal by header. That said, based on the OP comments, I think your solution is inline with the ask.

also, no need for glob unless using some wildcards, but since he is using ends_with, I assume */importer and *travelclaims would be necessary.

also, no need for glob unless using some wildcards, but since he is using ends_with, I assume */importer and *travelclaims would be necessary.

Thanks guys that seems to work fine.

Thanks guys that seems to work fine.

As Jason pointed out, there is no need for the -glob unless you are going to use Wildcards: “*/something” - equivalent to starts_with “/something*” - equivalent to ends_with “/something” - literal (requires exact match) I tend to look to the future when writing switch statements and should have pointed that out.

As Jason pointed out, there is no need for the -glob unless you are going to use Wildcards: “*/something” - equivalent to starts_with “/something*” - equivalent to ends_with “/something” - literal (requires exact match) I tend to look to the future when writing switch statements and should have pointed that out.

Hi Guy’s i did get it all to work with this in the end;

when HTTP_REQUEST { if { [HTTP::host] eq “dcc.dorsetforyou.com” and [HTTP::uri] starts_with “/Importer” } { pool glassfish-pool } elseif { [HTTP::host] eq “dcc.dorsetforyou.com” and [HTTP::uri] starts_with “/travelclaims” } { pool glassfish-pool } else { [HTTP::host] eq “dcc.dorsetforyou.com” } { HTTP::redirect “https://dorsetforyou.com” } }

Code

when HTTP_REQUEST { if { [HTTP::host] eq “dcc.dorsetforyou.com” and [HTTP::uri] starts_with “/Importer” } { pool glassfish-pool } elseif { [HTTP::host] eq “dcc.dorsetforyou.com” and [HTTP::uri] starts_with “/travelclaims” } { pool glassfish-pool } else { [HTTP::host] eq “dcc.dorsetforyou.com” } { HTTP::redirect “https://dorsetforyou.com” } }

when HTTP_REQUEST { if { [HTTP::host] eq “dcc.dorsetforyou.com” and [HTTP::uri] starts_with “/Importer” } { pool glassfish-pool } elseif { [HTTP::host] eq “dcc.dorsetforyou.com” and [HTTP::uri] starts_with “/travelclaims” } { pool glassfish-pool } else { [HTTP::host] eq “dcc.dorsetforyou.com” } { HTTP::redirect “https://dorsetforyou.com” } }