For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Ravi_Kumar_G_16's avatar
Ravi_Kumar_G_16
Icon for Nimbostratus rankNimbostratus
Aug 07, 2014

Need help in creating iRule

Hi All,

 

I need a iRUle which does the same work as following nginix rule

 

Nginix Rule

worker_processes 1; events { worker_connections 1024; }

 

http { include mime.types; default_type application/octet-stream;

 

sendfile on;

 

keepalive_timeout 65;

 

upstream xbase { server 192.168.10.101:18080; server 192.168.10.103:18080; }

 

upstream xiservice { server 192.168.10.101:8090; server 192.168.10.103:8090; }

 

upstream xirest { server 192.168.10.101:18080; server 192.168.10.103:18080; } server { listen 8888; server_name localhost;

 

location /xinsights/services/xbase/ { proxy_pass_header Set-Cookie; proxy_pass_header P3P; proxy_pass http://xbase/xinsightsrest/xbase/; } location /xinsights/xinsightsrest/ { proxy_pass_header Set-Cookie; proxy_pass_header P3P; proxy_pass http://xirest/xinsightsrest/; } location /xinsights/services/api/ { proxy_pass_header Set-Cookie; proxy_pass_header P3P; proxy_pass http://xiservice/api/; } location /xinsights/ui/ { proxy_pass_header Set-Cookie; proxy_pass_header P3P; proxy_pass http://xiservice/; } location / { root html; index index.html index.htm index.json; add_header Content-Type application/json; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }

 

}

1 Reply

  • Hi Ravi,

    Here's a hint - just guessing a few bits and left out a few, but should get you started;-

    pl_xbase_18080 members 192.168.10.101:18080 192.168.10.103:18080
    pl_xiservice members 192.168.10.101:8090 192.168.10.103:8090
    pl_xirest members 192.168.10.101:18080 192.168.10.103:18080
    

    then;-

    when HTTP_REQUEST {
       set fRoot 0
       switch [HTTP:: path] {
          "/xinsights/services/xbase/" { 
             pool pl_xbase_18080
             HTTP::uri "/xinsightsrest/xbase/" 
          }
          "xinsights/xinsightsrest/ { 
             pool pl_xirest_18080
             HTTP::uri "/xinsightsrest/"
          } 
          "/xinsights/services/api/ { 
             pool pl_xiservice_8090
             HTTP::uri "/api/"
          } 
          "/xinsights/ui/" { 
            pool pl_xiservice_8090
            HTTP::uri "/"
          } 
          "/" { 
             set fRoot 1
          }
    }
    when LB_FAILED {
       HTTP::respond 502 content [class match -value "502" dg_5xx_pages] noserver Retry-After 300
    }
    when HTTP_RESPONSE {
       if {$fRoot} {
          HTTP::header insert Content-Type "application/json"
       } 
    }
    

    You can also use a Local Traffic Policy to perform many of the iRule statements above.