Forum Discussion

ciscozest_30697's avatar
ciscozest_30697
Icon for Nimbostratus rankNimbostratus
Aug 03, 2018

iRule cannot fetch iFile (wpad.dat)

I am having issue with iRule. Once it is applied to VS, I cannot access internet anymore and always got error message "You've asked for something we don't have" which is the default event from iRule. I use the iRule template from other forum which looks good to me but I may have miss something here. The iRule, VS and iFile are in partition call MDD. attached screenshot is my iRule script.

 

I do not understand why I could not fetch the wpad.dat file successully. I have created three VS listening on below URL which is using /MDD/wpad.dat iRule as well but no luck: * using URL .../MDD/wpad.dat. * using URL . * using URL ...8080/MDD/wpad.dat.

 

Once I removed iRule from all VS, then I can access internet/ no issue. Any help is much appreciated.

 

regards,

 

  • Your iRule is changing the requested URI in lowercase then your first match case contains upper case characters, try the following:

    when HTTP_REQUEST {
      switch -glob [string tolower [HTTP:uri]] {
        "/mdd/wpad.dat" {
          HTTP::respond 200 contain [ifile get /MDD/wpad.dat] "Content-Type" "application/x-ns-proxy-autoconfig" "pragma" "no-cache"
        }
        default {
          HTTP::respond 404 content "You've asked for something we don't have."
        }  
      }
    }
    
  • Just guessing, Suspecting issue with external data source

    hxxp://x.x.x.x/MDD/wpad.dat
    .

    In this case iRule iFile is searching details inside F5 directory

    /config/filestore/files_d/Common_d/ifile_d

    Can you import wpad.dat file in F5 and run @AMG's iRule.

    System > File Management--> iFile List --> Import
    

    Hope will work...

    Cheers...

    • ciscozest_30697's avatar
      ciscozest_30697
      Icon for Nimbostratus rankNimbostratus

      Hi AMG and F5_Rock. Thanks for your support. I have checked the iFile exist and the Iruel scan be saved after validating the file path so it could be iFile content is not correct. Below is the brief content of wpad.dat file. Do you see any invalid parameters which could cause fetching issue?

       

      function FindProxyForURL(url, host) {

       

      // Send via proxy if (shExpMatch(url, "http://news.com.au/") || shExpMatch(host,"optus.com.au") ) return "PROXY webproxy.test-domain.com:8080";

       

      // Send direct if (shExpMatch(host,".yahoo.com") || shExpMatch(host,".telstra.com") || shExpMatch(host,"*.weather.com.au") ) return "DIRECT";

       

      // DEFAULT RULE: All other requests, send via proxy return "PROXY webproxy.test-domain.com:8080"; }

       

      regards, Rob

       

    • Andy_McGrath's avatar
      Andy_McGrath
      Icon for Cumulonimbus rankCumulonimbus

      Should be no issue with the iFile as simply plain text.

      Is the iFile and the Virtual Server you are assigning the iRule to in the same partition, i.e. both in partition named 'MDD'?

      If you try the following, removing the partition reference:

      when HTTP_REQUEST {
        switch -glob [string tolower [HTTP:uri]] {
          "/mdd/wpad.dat" {
            HTTP::respond 200 contain [ifile get wpad.dat] "Content-Type" "application/x-ns-proxy-autoconfig" "pragma" "no-cache"
          }
          default {
            HTTP::respond 404 content "You've asked for something we don't have."
          }  
        }
      }
      

      Failing this can you run the folllowing and share the output:

      tmsh list sys file ifile /MDD/wpad.dat
      tmsh list ltm ifile /MDD/wpad.dat
      
    • ciscozest_30697's avatar
      ciscozest_30697
      Icon for Nimbostratus rankNimbostratus

      I managed to fix the issue by changing iRule. Line 2-3 do not work so I replace them with simple "if { [HTTP::uri] starts_with "/wpad.dat" then client can fetch wpad file and browse properly now. Thanks AMG and F5_rock for your willingness to assist me.