F5 Sites
  • F5.com
  • F5 Labs
  • MyF5
  • NGINX
  • Partner Central
  • Education Services Portal (ESP)
Contact
  • Under Attack?
  • F5 Support
  • DevCentral Support
  • F5 Sales
  • NGINX Sales
  • F5 Professional Services
Skip to contentBrand Logo
Forums
CrowdSRC
Articles
GroupsEventsSuggestionsHow Do I...?
RegisterSign In
  1. DevCentral
  2. Articles
  3. Technical Articles

Multiple Certs, One VIP: TLS Server Name Indication via iRules

An age old question that we’ve seen time and time again in the iRules forums here on DevCentral is “How can I use iRules to manage multiple SSL certs on one VIP"?”. The answer has always historically...
Updated Aug 28, 2025
Version 2.0
adn
application delivery
availability
BIG-IP
code
dev
devops
disaster recovery
iRules
management
Colin_Walker_12's avatar
Colin_Walker_12
Historic F5 Account
Joined May 12, 2005
View Profile
nemmank's avatar
nemmank
Icon for Nimbostratus rankNimbostratus
Sep 03, 2019

Wouldn't it be simpler to just see a code that just worked. I mean practically, dead simple. I have searched severally but every advise I get suggest adding multiple ssl profiles to the same VIP and let the VIP auto-select the best server ssl to use. I mean this is like completely handing off critical decision making to random sense. What if the server ssl are incorrectly selected and this leave room for difficult in pin-pointing the failure. I managed to put together few ideas and have an irule that really works, provides logging if the wrong ssl profile or nothing is selected. You need to prepare the fqdn or server IP:port pools to go with it though:

 

1) Create ephemeral Pools point to new fqdn or server IP:port pools

 

a) fqdn-a.new_fqdn_pool

b) fqdn-b.new_fqdn_pool

c) fqdn-c.new_fqdn_pool

d) fqdn-d.new_fqdn_pool

 

2) Create Server SSL profile for each of the new fqdn destination urls:

 

a) fqdn-a_serverssl

b) fqdn-b_serverssl

c) fqdn-c_serverssl

d) fqdn-d_serverssl

 

3) Create new iRule and attach to inbound VIP

when HTTP_REQUEST {

 

  # Inspect inbound host header and replace based on original url

  

  switch [HTTP::host] {

  "fqdn-a.original_fqdn" {

   set new_fqdn "fqdn-a.new_fqdn"

 set doSSL 1

 SSL::enable serverside

  }

  "fqdn-b.original_fqdn" {

   set new_fqdn "fqdn-b.new_fqdn"

 set doSSL 2

 SSL::enable serverside

  }

  "fqdn-c.original_fqdn" {

   set new_fqdn "fqdn-c.new_fqdn"

 set doSSL 3

 SSL::enable serverside

  }

  "fqdn-d.original_fqdn" {

   set new_fqdn "fqdn-d.new_fqdn"

 set doSSL 4

 SSL::enable serverside

  }

  default {

   log local0. "Inbound fqdn not known: [HTTP::host]"

 reject

  }

  }

 

  HTTP::header replace Host $new_fqdn

  pool ${new_fqdn}_pool

 

}

when SERVER_CONNECTED {

  #doSSL variable is checked and SSL disabled or profile selected

  if {$doSSL == 1} {

    SSL::profile fqdn-a_serverssl

log "Using Server SSL fqdn-a_serverssl"

  } elseif {$doSSL == 2} {

    SSL::profile fqdn-b_serverssl

log "Using Server SSL fqdn-b_serverssl"

  } elseif {$doSSL == 3} {

    SSL::profile fqdn-c_serverssl

log "Using Server SSL fqdn-c_serverssl"

  } elseif {$doSSL == 4} {

    SSL::profile fqdn-d_serverssl

log "Using Server SSL fqdn-d_serverssl"

  }

}

Help guide the future of your DevCentral Community!

What tools do you use to collaborate? (1min - anonymous)

ABOUT DEVCENTRAL

DevCentral NewsTechnical ForumTechnical ArticlesTechnical CrowdSRCCommunity GuidelinesDevCentral EULAGet a Developer Lab LicenseBecome a DevCentral MVP

RESOURCES

Product DocumentationWhite PapersGlossaryCustomer StoriesWebinarsFree Online CoursesTraining & Certification

SUPPORT

Manage SubscriptionsProfessional ServicesCreate a Service RequestSoftware DownloadsSupport Portal

PARTNERS

Find a Reseller PartnerTechnology AlliancesBecome an F5 PartnerLogin to Partner Central

©2024 F5, Inc. All rights reserved.
TrademarksPoliciesPrivacyCalifornia PrivacyDo Not Sell My Personal Information