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

TLBrown_220661's avatar
TLBrown_220661
Icon for Nimbostratus rankNimbostratus
Oct 05, 2015

Need help with pool selection based on URI

This rule doesn't show any syntax errors in the editor, but I am not getting traffic to the pools. The rule resides in the Common partition and points to the pools using a path structure:

 

when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/accountsearchdev.somewhere.com/" { pool "/test-partition/accountsearchdev.somewhere.com-1080" } "/maintenancedev.somewhere.com/" { pool "/test-partition/maintenancedev.somewhere.com-1081" } "/passportnetdev.somewhere.com/" { pool "/test-partition/passportnetdev.somewhere.com-1082" log "Matched to passportnetdev.somewhere.com-1082"} "/agentsearchdev.somewhere.com/" { pool "/test-partition/agentsearchdev.somewhere.com-1083" } "/contracdev.somewhere.com/" { pool "/test-partition/contracdev.somewhere.com-1084" } "/mftransferdev.somewhere.com/" { pool "/test-partition/mftransferdev.somewhere.com-1085" } "/mfreportsdev.somewhere.com/" { pool "/test-partition/mfreportsdev.somewhere.com-1086" } "/esignaturereportsdev.somewhere.com/" { pool "/test-partition/esignaturereportsdev.somewhere.com-1087" } "/helpdeskdev.somewhere.com/" { pool "/test-partition/helpdeskdev.somewhere.com-1088" } "/batchimportmgrdev.somewhere.com/" { pool "/test-partition/batchimportmgrdev.somewhere.com-1089" } "/iprmdev.somewhere.com/" { pool "/test-partition/iprmdev.somewhere.com-1090" } "/passportadmindev.somewhere.com/" { pool "/test-partition/passportadmindev.somewhere.com-1091" } "/prevailintegrationdev.somewhere.com/" { pool "/test-partition/prevailintegrationdev.somewhere.com-1092" } "/qivadmindev.somewhere.com/" { pool "/test-partition/qivadmindev.somewhere.com-1093" } "/qivconfigdev.somewhere.com/" { pool "/test-partition/qivconfigdev.somewhere.com-1094" } "/quotetracdev.somewhere.com/" { pool "/test-partition/quotetracdev.somewhere.com-1095" } "/stratreportdev.somewhere.com/" { pool "/test-partition/stratreportdev.somewhere.com-1096" } default { log "Request: [HTTP::uri] from [IP::client_addr] failed - no match in list" }}}

 

11 Replies

  • Hi!

    You can try this rule to see what's coming in:

    when HTTP_REQUEST {
    
        log local0. "Incoming URI: [string tolower [HTTP::uri]]"
    
        switch -glob [string tolower [HTTP::uri]] { 
            "/accountsearchdev.somewhere.com/" { pool "/test-partition/accountsearchdev.somewhere.com-1080" }
            "/maintenancedev.somewhere.com/" { pool "/test-partition/maintenancedev.somewhere.com-1081" }
            "/passportnetdev.somewhere.com/" { pool "/test-partition/passportnetdev.somewhere.com-1082" log "Matched to passportnetdev.somewhere.com-1082" } 
            "/agentsearchdev.somewhere.com/" { pool "/test-partition/agentsearchdev.somewhere.com-1083" }
            "/contracdev.somewhere.com/" { pool "/test-partition/contracdev.somewhere.com-1084" }
            "/mftransferdev.somewhere.com/" { pool "/test-partition/mftransferdev.somewhere.com-1085" }
            "/mfreportsdev.somewhere.com/" { pool "/test-partition/mfreportsdev.somewhere.com-1086" }
            "/esignaturereportsdev.somewhere.com/" { pool "/test-partition/esignaturereportsdev.somewhere.com-1087" }
            "/helpdeskdev.somewhere.com/" { pool "/test-partition/helpdeskdev.somewhere.com-1088" }
            "/batchimportmgrdev.somewhere.com/" { pool "/test-partition/batchimportmgrdev.somewhere.com-1089" }
            "/iprmdev.somewhere.com/" { pool "/test-partition/iprmdev.somewhere.com-1090" }
            "/passportadmindev.somewhere.com/" { pool "/test-partition/passportadmindev.somewhere.com-1091" }
            "/prevailintegrationdev.somewhere.com/" { pool "/test-partition/prevailintegrationdev.somewhere.com-1092" }
            "/qivadmindev.somewhere.com/" { pool "/test-partition/qivadmindev.somewhere.com-1093" }
            "/qivconfigdev.somewhere.com/" { pool "/test-partition/qivconfigdev.somewhere.com-1094" }
            "/quotetracdev.somewhere.com/" { pool "/test-partition/quotetracdev.somewhere.com-1095" }
            "/stratreportdev.somewhere.com/" { pool "/test-partition/stratreportdev.somewhere.com-1096" } 
            default { log "Request: [HTTP::uri] from [IP::client_addr] failed - no match in list" }
        }
    }
    

    This rule only matches URI's that is an exact match.

    Ie.

    It will match but not

    If you want to match you need to add a wildcard. Something like this:

    when HTTP_REQUEST {
    
        log local0. "Incoming URI: [string tolower [HTTP::uri]]"
    
        switch  [string tolower [HTTP::uri]] { 
            "/accountsearchdev.somewhere.com/*" { pool "/test-partition/accountsearchdev.somewhere.com-1080" }
            "/maintenancedev.somewhere.com/*" { pool "/test-partition/maintenancedev.somewhere.com-1081" }
            "/passportnetdev.somewhere.com/*" { pool "/test-partition/passportnetdev.somewhere.com-1082" log "Matched to passportnetdev.somewhere.com-1082" } 
            "/agentsearchdev.somewhere.com/*" { pool "/test-partition/agentsearchdev.somewhere.com-1083" }
            "/contracdev.somewhere.com/*" { pool "/test-partition/contracdev.somewhere.com-1084" }
            "/mftransferdev.somewhere.com/*" { pool "/test-partition/mftransferdev.somewhere.com-1085" }
            "/mfreportsdev.somewhere.com/*" { pool "/test-partition/mfreportsdev.somewhere.com-1086" }
            "/esignaturereportsdev.somewhere.com/*" { pool "/test-partition/esignaturereportsdev.somewhere.com-1087" }
            "/helpdeskdev.somewhere.com/*" { pool "/test-partition/helpdeskdev.somewhere.com-1088" }
            "/batchimportmgrdev.somewhere.com/*" { pool "/test-partition/batchimportmgrdev.somewhere.com-1089" }
            "/iprmdev.somewhere.com/*" { pool "/test-partition/iprmdev.somewhere.com-1090" }
            "/passportadmindev.somewhere.com/*" { pool "/test-partition/passportadmindev.somewhere.com-1091" }
            "/prevailintegrationdev.somewhere.com/*" { pool "/test-partition/prevailintegrationdev.somewhere.com-1092" }
            "/qivadmindev.somewhere.com/*" { pool "/test-partition/qivadmindev.somewhere.com-1093" }
            "/qivconfigdev.somewhere.com/*" { pool "/test-partition/qivconfigdev.somewhere.com-1094" }
            "/quotetracdev.somewhere.com/*" { pool "/test-partition/quotetracdev.somewhere.com-1095" }
            "/stratreportdev.somewhere.com/*" { pool "/test-partition/stratreportdev.somewhere.com-1096" } 
            default { log "Request: [HTTP::uri] from [IP::client_addr] failed - no match in list" }
        }
    }
    

    Hope that helps.

    /Patrik

  • That's very odd - when I pasted the rule in here it had *s in it - looking to match the phrase no matter what precedes or folows it - let me try again:

     

    when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/accountsearchdev.somewhere.com/" { pool "/test-partition/accountsearchdev.somewhere.com-1080" } "/maintenancedev.somewhere.com/" { pool "/test-partition/maintenancedev.somewhere.com-1081" } "/passportnetdev.somewhere.com/" { pool "/test-partition/passportnetdev.somewhere.com-1082" log "Matched to passportnetdev.somewhere.com-1082"} "/agentsearchdev.somewhere.com/" { pool "/test-partition/agentsearchdev.somewhere.com-1083" } "/contracdev.somewhere.com/" { pool "/test-partition/contracdev.somewhere.com-1084" } "/mftransferdev.somewhere.com/" { pool "/test-partition/mftransferdev.somewhere.com-1085" } "/mfreportsdev.somewhere.com/" { pool "/test-partition/mfreportsdev.somewhere.com-1086" } "/esignaturereportsdev.somewhere.com/" { pool "/test-partition/esignaturereportsdev.somewhere.com-1087" } "/helpdeskdev.somewhere.com/" { pool "/test-partition/helpdeskdev.somewhere.com-1088" } "/batchimportmgrdev.somewhere.com/" { pool "/test-partition/batchimportmgrdev.somewhere.com-1089" } "/iprmdev.somewhere.com/" { pool "/test-partition/iprmdev.somewhere.com-1090" } "/passportadmindev.somewhere.com/" { pool "/test-partition/passportadmindev.somewhere.com-1091" } "/prevailintegrationdev.somewhere.com/" { pool "/test-partition/prevailintegrationdev.somewhere.com-1092" } "/qivadmindev.somewhere.com/" { pool "/test-partition/qivadmindev.somewhere.com-1093" } "/qivconfigdev.somewhere.com/" { pool "/test-partition/qivconfigdev.somewhere.com-1094" } "/quotetracdev.somewhere.com/" { pool "/test-partition/quotetracdev.somewhere.com-1095" } "/stratreportdev.somewhere.com/" { pool "/test-partition/stratreportdev.somewhere.com-1096" } default { log "Request: [HTTP::uri] from [IP::client_addr] failed - no match in list" }}}

     

    • Patrik_Jonsson's avatar
      Patrik_Jonsson
      Icon for MVP rankMVP
      Please use the preformatted code option in the forum. The rule is unreadable and I don't really feel like formatting it again for you. :)
  • when HTTP_REQUEST {
    switch -glob [string tolower [HTTP::uri]] {
    "*/accountsearchdev.somewhere.com/*" { pool "/test-partition/accountsearchdev.somewhere.com-1080" }
    "*/maintenancedev.somewhere.com/*" { pool "/test-partition/maintenancedev.somewhere.com-1081" }
    "*/passportnetdev.somewhere.com/*" { pool "/test-partition/passportnetdev.somewhere.com-1082" log "Matched to passportnetdev.somewhere.com-1082"}
    "*/agentsearchdev.somewhere.com/*" { pool "/test-partition/agentsearchdev.somewhere.com-1083" }
    "*/contracdev.somewhere.com/*" { pool "/test-partition/contracdev.somewhere.com-1084" }
    "*/mftransferdev.somewhere.com/*" { pool "/test-partition/mftransferdev.somewhere.com-1085" }
    "*/mfreportsdev.somewhere.com/*" { pool "/test-partition/mfreportsdev.somewhere.com-1086" }
    "*/esignaturereportsdev.somewhere.com/*" { pool "/test-partition/esignaturereportsdev.somewhere.com-1087" }
    "*/helpdeskdev.somewhere.com/*" { pool "/test-partition/helpdeskdev.somewhere.com-1088" }
    "*/batchimportmgrdev.somewhere.com/*" { pool "/test-partition/batchimportmgrdev.somewhere.com-1089" }
    "/*iprmdev.somewhere.com/*" { pool "/test-partition/iprmdev.somewhere.com-1090" }
    "/*passportadmindev.somewhere.com/*" { pool "/test-partition/passportadmindev.somewhere.com-1091" }
    "/*prevailintegrationdev.somewhere.com/*" { pool "/test-partition/prevailintegrationdev.somewhere.com-1092" }
    "*/qivadmindev.somewhere.com/*" { pool "/test-partition/qivadmindev.somewhere.com-1093" }
    "*/qivconfigdev.somewhere.com/*" { pool "/test-partition/qivconfigdev.somewhere.com-1094" }
    "*/quotetracdev.somewhere.com/*" { pool "/test-partition/quotetracdev.somewhere.com-1095" }
    "*/stratreportdev.somewhere.com/*" { pool "/test-partition/stratreportdev.somewhere.com-1096" }
    default { log "Request: [HTTP::uri] from [IP::client_addr] failed - no match in list" }}}
    
  • Please add this one as I suggested earlier to see what the incoming URI is:

    log local0. "Incoming URI: [string tolower [HTTP::uri]]"
    

    That might help figuring out why it does not match any of the cases.

    /Patrik

  • That's too bad. Since they wont let you change things I assume the request are actually landing somewhere? Can't you check the Web server logs?

     

    /Patrik

     

  • Hi,

    [HTTP::uri]
    does not contains hostname,
    [HTTP::host]
    is the right variable in the switch command.

    when HTTP_REQUEST {
    switch  [string tolower [HTTP::host]] {
        "accountsearchdev.somewhere.com" { pool "/test-partition/accountsearchdev.somewhere.com-1080" }
        "maintenancedev.somewhere.com" { pool "/test-partition/maintenancedev.somewhere.com-1081" }
        "passportnetdev.somewhere.com" { pool "/test-partition/passportnetdev.somewhere.com-1082" log "Matched to passportnetdev.somewhere.com-1082"}
        default { log "Request: [HTTP::host] from [IP::client_addr] failed - no match in list" }
        }
    }