Forum Discussion
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 ?
- Michael_YatesNimbostratus
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.
- JRahmAdminit 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.
- JRahmAdminalso, no need for glob unless using some wildcards, but since he is using ends_with, I assume */importer and *travelclaims would be necessary.
- paul_dccNimbostratusThanks guys that seems to work fine.
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.
- JRahmAdminit 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.
- JRahmAdminalso, no need for glob unless using some wildcards, but since he is using ends_with, I assume */importer and *travelclaims would be necessary.
- paul_dccNimbostratusThanks guys that seems to work fine.
- paul_dccNimbostratus
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" } }
- paul_dccNimbostratus
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" } }
- paul_dccNimbostratus
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" } }
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com