Forum Discussion

Apache1048_5684's avatar
Apache1048_5684
Icon for Nimbostratus rankNimbostratus
Sep 26, 2017

Irule based on host name contains to redirect

I am working with Peppol and need an irule that will redirect based on a wildcard URL

The URL will end with ".publisher.edelivery.tech.ec.europa.eu" and the beginning could be any string. Ours

elcom-smp-test.publisher.edelivery.tech.ec.europa.eu

So far I have tried multiple combinations of ends_with and contains but no joy. We use

when HTTP_REQUEST {
    switch [HTTP::host] {
      smpdev.elcom.com { pool smpdev-pool }
      smpqa.elcom.com { pool smpqa-pool  }
      smptest.elcom.com { pool smptest-pool }
      elcom-smp-test.publisher.edelivery.tech.ec.europa.eu { pool smptest-pool }
      default { reject }
    }
  }

but I need the last line to match the last portion (publisher.edelivery.tech.ec.europa.eu) of the host name - is that possible?

1 Reply

  • Hi,

    you can use glog option in switch command allowing wildcard:

    when HTTP_REQUEST {
        switch -glob -- [HTTP::host] {
          "smpdev.elcom.com" { pool smpdev-pool }
          "smpqa.elcom.com" { pool smpqa-pool  }
          "smptest.elcom.com" { pool smptest-pool }
          "*.publisher.edelivery.tech.ec.europa.eu" { pool smptest-pool }
          default { reject }
        }
      }