# irule for selecting pool based upon https website request

**URL:** <https://community.f5.com/t/irule-for-selecting-pool-based-upon-https-website-request/4660>\
**Category:** Technical Forums\
**Tags:** deployment, availability, virtualization, big-ip-access-policy-manager-apm, irules, devops, security, application-delivery\
**Created:** [June 25, 2014, 4:55pm UTC](https://community.f5.com/t/irule-for-selecting-pool-based-upon-https-website-request/4660 "2014-06-25T16:55:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anil\_Gupta\_01\_1](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@Anil\_Gupta\_01\_1](https://community.f5.com/u/Anil_Gupta_01_1)\
**Post date:** [June 25, 2014, 4:55pm UTC](https://community.f5.com/t/irule-for-selecting-pool-based-upon-https-website-request/4660/1 "2014-06-25T16:55:01Z")

</div>

Hi,

We have Microsoft TMG server who is publishing our three website with one single Public IP address. As Microsoft TMG is EOL and EOS, We are planning to migrate the website on F5 LTM.

My Query is, how many VS, we need to create for publishing three website on F5 LTM and below irule will work if we create single VS and map the below irule.

We have created the below irule; need to know, whether it will work or not. when HTTP\_REQUEST { if { [HTTP::uri] contains “[aol.xyz.com](http://aol.xyz.com)” } { pool aol\_pool } ifelse { [HTTP::uri] contains “[yahoo.xyz.com](http://yahoo.xyz.com)” } { pool yahoo\_pool } ifelse { [HTTP::uri] contains “[google.xyz.com](http://google.xyz.com)” } { pool google\_pool } else { discard } }

any help is welcome.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Cory\_50405](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@Cory\_50405](https://community.f5.com/u/Cory_50405)\
**Post date:** [June 25, 2014, 5:02pm UTC](https://community.f5.com/t/irule-for-selecting-pool-based-upon-https-website-request/4660/2 "2014-06-25T17:02:13Z")

</div>

Try this:

```tcl
when HTTP_REQUEST { 
 if { [HTTP::host] equals "aol.xyz.com" } { 
  pool aol_pool 
 } elseif { [HTTP::host] equals "yahoo.xyz.com" } { 
  pool yahoo_pool 
 } elseif { [HTTP::host] equals "google.xyz.com" } { 
  pool google_pool 
 } else { discard } 
}

```

---

<div class="post-metadata">

**Author:** ![Cory\_50405](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@Cory\_50405](https://community.f5.com/u/Cory_50405)\
**Post date:** [June 25, 2014, 5:05pm UTC](https://community.f5.com/t/irule-for-selecting-pool-based-upon-https-website-request/4660/3 "2014-06-25T17:05:07Z")

</div>

To add to this, you must be terminating SSL on this virtual server in order to inspect the HTTP host header. Looks like you’ll probably need a wildcard certificate for that if you don’t already have one.

---

<div class="post-metadata">

**Author:** ![Kevin\_O\_39\_Nei](https://avatars.discourse-cdn.com/v4/letter/k/90db22/32.png) [@Kevin\_O\_39\_Nei](https://community.f5.com/u/Kevin_O_39_Nei)\
**Post date:** [June 25, 2014, 5:08pm UTC](https://community.f5.com/t/irule-for-selecting-pool-based-upon-https-website-request/4660/4 "2014-06-25T17:08:34Z")

</div>

Here is a version that we implemented on an LTM 3600 running 9.4.5.

Farm Name: firefly-qa-farms.qa.oclc.org:80

rule firefly\_qa\_farm\_to\_pool\_rule { when HTTP\_REQUEST { if { [HTTP::header exists “Host”] } { set host\_name [string tolower [HTTP::header “Host”]] set pool\_name [findclass $host\_name $::firefly\_qa\_name\_to\_pool\_class " "] if { $pool\_name ne “” } { use pool $pool\_name } else { log local0. “No pool for host name:$host\_name; TCP local port:[TCP::local\_port]; client IP addr:[IP::client\_addr];\ client TCP port:[TCP::client\_port]; METHOD:[HTTP::method]; URI:[HTTP::uri]” reject } } else { log local0. “No Host in HTTP header; TCP local port:[TCP::local\_port]; client IP addr:[IP::client\_addr];\ client TCP port:[TCP::client\_port]; METHOD:[HTTP::method];URI:[HTTP::uri]” reject } } }

class firefly\_qa\_name\_to\_pool\_class { “[firefly-enva.qa.oclc.org](http://firefly-enva.qa.oclc.org) firefly-enva\_qa\_7050” “[firefly-envb.qa.oclc.org](http://firefly-envb.qa.oclc.org) firefly-envb\_qa\_7050” “[firefly-envc.qa.oclc.org](http://firefly-envc.qa.oclc.org) firefly-envc\_qa\_7050” “[firefly-envi.qa.oclc.org](http://firefly-envi.qa.oclc.org) firefly-envi\_qa\_7050” “[firefly-envj.qa.oclc.org](http://firefly-envj.qa.oclc.org) firefly-envj\_qa\_7050” “[firefly-envl.qa.oclc.org](http://firefly-envl.qa.oclc.org) firefly-envl\_qa\_7050” “[firefly-envm.qa.oclc.org](http://firefly-envm.qa.oclc.org) firefly-envm\_qa\_7050” “[firefly-envn.qa.oclc.org](http://firefly-envn.qa.oclc.org) firefly-envn\_qa\_7050” “[firefly-envo.qa.oclc.org](http://firefly-envo.qa.oclc.org) firefly-envo\_qa\_7050” “[firefly-envp.qa.oclc.org](http://firefly-envp.qa.oclc.org) firefly-envp\_qa\_7050” “[firefly-envr.qa.oclc.org](http://firefly-envr.qa.oclc.org) firefly-envr\_qa\_7050” “[firefly-envs.qa.oclc.org](http://firefly-envs.qa.oclc.org) firefly-envs\_qa\_7050” “[firefly-envt.qa.oclc.org](http://firefly-envt.qa.oclc.org) firefly-envt\_qa\_7050” “[firefly-envu.qa.oclc.org](http://firefly-envu.qa.oclc.org) firefly-envu\_qa\_7050” “[firefly-envx.qa.oclc.org](http://firefly-envx.qa.oclc.org) firefly-envx\_qa\_7050” “[firefly-envz.qa.oclc.org](http://firefly-envz.qa.oclc.org) firefly-envz\_qa\_7050” “[firefly-qaperf23.qa.oclc.org](http://firefly-qaperf23.qa.oclc.org) firefly-qaperf23\_qa\_7050” “[firefly-qaperf24.qa.oclc.org](http://firefly-qaperf24.qa.oclc.org) firefly-qaperf24\_qa\_7050” }

---

<div class="post-metadata">

**Author:** ![Kevin\_O\_39\_Nei](https://avatars.discourse-cdn.com/v4/letter/k/90db22/32.png) [@Kevin\_O\_39\_Nei](https://community.f5.com/u/Kevin_O_39_Nei)\
**Post date:** [June 25, 2014, 5:10pm UTC](https://community.f5.com/t/irule-for-selecting-pool-based-upon-https-website-request/4660/5 "2014-06-25T17:10:15Z")

</div>

Lost the formatting of the code. Sorry. --Kevin

---

<div class="post-metadata">

**Author:** ![Anil\_Gupta\_01\_1](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@Anil\_Gupta\_01\_1](https://community.f5.com/u/Anil_Gupta_01_1)\
**Post date:** [June 25, 2014, 5:10pm UTC](https://community.f5.com/t/irule-for-selecting-pool-based-upon-https-website-request/4660/6 "2014-06-25T17:10:56Z")

</div>

one more small query;

I hope, I need to create virtual server on port 443 (since end user will access via https) and need to create and select the irule as mention above.

below is My pool details for reference. aol\_pool is working on 8040 port; yahoo\_pool is working on 8060 port; google\_pool is working on 8080 port;
