HTTP with iRule inline BIG-IP Next AS3 Example DeclarationΒΆ

HTTP application with an iRule in a service configuration, with iRule inline

{
     "class": "ADC",
     "id": "id-irule-inline",
     "schemaVersion": "3.0.0",
     "mytenant": {
       "class": "Tenant",
       "myapp": {
         "class": "Application",
         "my_irule_1": {
           "class": "iRule",
           "iRule": "when HTTP_REQUEST {\n  if { ([string match {[A-Z]} [HTTP::uri]] and [[HTTP::path] ends_with \".aspx\"])} {\n    set hostname [string tolower [HTTP::host]]\n    set uriname [string tolower [HTTP::uri]]\n    log local0. \"Request is $hostname$uriname\"\n    HTTP::redirect \"http://$hostname$uriname\"\n  }\n}"
         },
         "my_irule_2": {
           "class": "iRule",
           "iRule": {
             "text": "when HTTP_REQUEST {\n  if { ([string match {[A-Z]} [HTTP::uri]] and [[HTTP::path] ends_with \".aspx\"])} {\n    set hostname [string tolower [HTTP::host]]\n    set uriname [string tolower [HTTP::uri]]\n    log local0. \"Request is $hostname$uriname\"\n    HTTP::redirect \"http://$hostname$uriname\"\n  }\n}"
           }
         },
         "my_irule_3": {
           "class": "iRule",
           "iRule": {
             "base64": "d2hlbiBIVFRQX1JFUVVFU1QgewogIGlmIHsgKFtzdHJpbmcgbWF0Y2gge1tBLVpdfSBbSFRUUDo6dXJpXV0gYW5kIFtbSFRUUDo6cGF0aF0gZW5kc193aXRoICIuYXNweCJdKX0gewogICAgc2V0IGhvc3RuYW1lIFtzdHJpbmcgdG9sb3dlciBbSFRUUDo6aG9zdF1dCiAgICBzZXQgdXJpbmFtZSBbc3RyaW5nIHRvbG93ZXIgW0hUVFA6OnVyaV1dCiAgICBsb2cgbG9jYWwwLiAiUmVxdWVzdCBpcyAkaG9zdG5hbWUkdXJpbmFtZSIKICAgIEhUVFA6OnJlZGlyZWN0ICJodHRwOi8vJGhvc3RuYW1lJHVyaW5hbWUiCiAgfQp9"
           }
         },
         "my_irule_4": {
           "class": "iRule",
           "iRule": "when HTTP_REQUEST {\n  if { ([string match {[A-Z]} [HTTP::uri]] and [[HTTP::path] ends_with \".aspx\"])} {\n    set hostname [string tolower [HTTP::host]]\n    set uriname [string tolower [HTTP::uri]]\n    log local0. \"Request is $hostname$uriname\"\n    HTTP::redirect \"http://$hostname$uriname\"\n  }\n}"
         },
         "my_pool": {
           "class": "Pool",
           "loadBalancingMode": "least-connections-member",
           "members": [
             {
               "serverAddresses": [
                 "198.18.10.10"
               ],
               "servicePort": 80
             }
           ]
         },
         "my_service": {
           "class": "Service_HTTP",
           "iRules": [
             "my_irule_1",
             "my_irule_2",
             "my_irule_3",
             {
               "use": "my_irule_4"
             }
           ],
           "pool": "my_pool",
           "virtualAddresses": [
             "198.18.1.10"
           ],
           "virtualPort": 80
         }
       }
     }
   }