+ Post New Thread
Results 1 to 13 of 13
Windows Thread, proxy .pac file in Technical; ive done a search and can come up with nothing i quite get. Im trying to write a pac file ...
  1. #1


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,589
    Thank Post
    228
    Thanked 856 Times in 735 Posts
    Rep Power
    296

    proxy .pac file

    ive done a search and can come up with nothing i quite get.

    Im trying to write a pac file so when ip address starts with 10 (i would of thought keeps it simple) it uses a proxy if it dosent it wont (so teachers can take laptops home (they do have reg file on the desktop to turn the proxy on and off but aparantly thats too techincal/hard/cant be bothered for some of them))

    from what i can gather my script should work but it seems to do nothing and i cant see why as it seems that 0 function as a wildcard so my read on the code is basically if my ip is 10.whatever use a proxy if its not dont but when i try it it dosent use a proxy at all any ideas? I cant even see a way of checking the output other than running ie and it failing to go to a website

    Code:
    function FindProxyForURL(url, host)
    {
    if (isInNet(myIpAddress(),"10.0.0.0","255.255.252.0"))
    return "PROXY myproxy.local:80";
    else
    return "DIRECT";
    }

  2. #2
    k-strider's Avatar
    Join Date
    Oct 2006
    Location
    Gloucester
    Posts
    357
    Thank Post
    7
    Thanked 40 Times in 30 Posts
    Rep Power
    23
    i couldn't get this to work either.

    what you could do is host the .PAC file on a web server and set the clients to auto detect as when they get home that will work too..

    you need to register an a record wpad and point it to the webserver
    then in the root of the web server call your PAC file wpad.dat

    Code:
    if (isInNet(host, "10.7.56.0", "255.255.252.0")) {
       return "DIRECT";}
    
    return "PROXY proxy.thecryptschool.lan:8080; DIRECT";

  3. #3
    Jamo's Avatar
    Join Date
    Jan 2009
    Posts
    1,350
    Thank Post
    66
    Thanked 175 Times in 147 Posts
    Rep Power
    60
    This site seems quite useful on the setup of autoconfig files

    Cache Auto-config

  4. #4


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,589
    Thank Post
    228
    Thanked 856 Times in 735 Posts
    Rep Power
    296
    Quote Originally Posted by Jamo View Post
    This site seems quite useful on the setup of autoconfig files

    Cache Auto-config

    damn lea filtering its blocked

  5. #5
    soveryapt's Avatar
    Join Date
    Jan 2009
    Location
    Lancashire
    Posts
    2,402
    Thank Post
    648
    Thanked 277 Times in 244 Posts
    Rep Power
    78

    Are you using GPOs on your network?

    If you use GPOs on your network, you can simply set the GPO (for the computer I think it is off hand I'm on a different site at the moment without an AD in place .. .. ooo RDP .. hang on)

    Right...

    Under the USER settings (not computer as I initially though!) under Internet Explorer Maintenance (you may need to download the Admin Template for it from Microsoft) under Connection then choose Automatic Browser Configuration and put the details to your proxy.pac in there (obviously enable it first) and make sure this is on a machine that is in your school (so your server if you have IIS set up for instance, but then you'll have to ensure you make sure you set up the correct MIME type for the .pac file so it knows how to handle it.

    Once this is done, the staff laptop will simply know from the GPO to look for the proxy.pac (or whatever you call it) at http://your.server.address/proxy.pac. If that machine is on the network then GREAT, it finds it, all your proxies are set up and everything works .. however, when they're out of school, it can't find the proxy.pac file and simply reverts to looking for automatic settings from the staffs own home internet.

    I hope that makes sense, it took me ages to figure it out with lots of test settings, but when I got it to work, it's been great ever since with no more pitchforks and flaming torches waiting at my desk accompanied by angry staff members as they couldn't get onto Facebook or something, I mean work related sites! lol ..

  6. #6

    Join Date
    May 2009
    Location
    Darlo
    Posts
    70
    Thank Post
    0
    Thanked 12 Times in 7 Posts
    Rep Power
    13
    This the .pac file we use & it seems to work -

    function FindProxyForURL(url, host)
    {
    if (isPlainHostName(host) || localHostOrDomainIs(host, "10.0.0.200") || localHostOrDomainIs(host, "smoothwall.yourdomain.name"))
    return "DIRECT";

    else
    return "PROXY 10.0.0.200:8080";
    }

  7. #7


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339
    Code:
    function FindProxyForURL(url, host)
    {
    
    // Variable strings to return
    
    var proxy_yes = "PROXY 172.16.0.197:8000";
    var proxy_no = "DIRECT";
    
    // Execptions for direct connection
    
    if (shExpMatch(url, "http://printers:9191/*")) { return proxy_no; }
    if (shExpMatch(url, "https://printers:9191/*")) { return proxy_no; }
    if (shExpMatch(url, "http://zimbra/*")) { return proxy_no; }
    if (shExpMatch(url, "https://zimbra/*")) { return proxy_no; }
    if (shExpMatch(url, "http://server1*")) { return proxy_no; }
    if (shExpMatch(url, "https://server1*")) { return proxy_no; }
    
    
    // Proxy if PC is on local LAN
    
    if (isInNet(myIpAddress(), "172.16.0.0", "255.255.0.0"))
    return "PROXY 172.16.0.197:8000";
    
    // Below for Firefox bug when running on Linux by checking localhost
    
    else if (isInNet(myIpAddress(), "127.0.0.0", "255.0.0.0"))
    return "PROXY 172.16.0.197:8000";
    
    // Everything else to go direct
    
    else
    return "DIRECT";
    }

  8. #8
    HullFC's Avatar
    Join Date
    Sep 2009
    Posts
    23
    Thank Post
    3
    Thanked 8 Times in 7 Posts
    Rep Power
    11

    My first post - Coming up, proxy auto detect

    Hi All,

    My next post is about auto detecting proxy settings but I can't posts links in my first post so...

    Hello and read on!

    Shaun

  9. #9
    HullFC's Avatar
    Join Date
    Sep 2009
    Posts
    23
    Thank Post
    3
    Thanked 8 Times in 7 Posts
    Rep Power
    11

    Proxy auto detection

    Hi All,

    This is how I have proxy autoconfig set up in a number of primary schools.

    I used this information: FindProxyForURL.com - PAC & WPAD Resource (sorry, 1st post won't let me do URL links)

    The important parts are...

    ...choosing to use either DNS or DHCP (or both). I use DNS personally as some PC's are on static IPs

    ...making sure you add the mime type (.dat = application/ns-proxy-autoconfig) on your web server

    ...keeping your wpad simple and expand it (exceptions) when you know it works
    Make sure to test at each stage:

    ...knowing that WPAD as a dns entry may be blocked. If you can't ping it, your clients can't download the pac/wpad file. Do a search online about unblocking this but read the security rasons why it is blocked.

    ...testing the download of the wpad/pac in your browser. e.g. http://wpad/wpad.dat.

    Hope this helps. The link above was really useful to me.

    Shaun

  10. #10

    Join Date
    Sep 2007
    Posts
    90
    Thank Post
    7
    Thanked 32 Times in 17 Posts
    Rep Power
    20

    alternatively...

    alternatively you could use ProxySwitcher from:
    Onyx Box

    "...Proxy Switcher is a small tray icon type utility that allows you to select whether Windows and Mozilla Firefox should use a proxy server for Internet access in a couple of clicks..."
    Unfortunately it's no longer freeware since i last downloaded it earlier this year, but i could send you the last freeware version...or you could send the guy a donation.

  11. #11
    k-strider's Avatar
    Join Date
    Oct 2006
    Location
    Gloucester
    Posts
    357
    Thank Post
    7
    Thanked 40 Times in 30 Posts
    Rep Power
    23
    we actually isntall proxypal (which is free) on our staff laptops and put the button next to the home button it simply enables and disables the proxy at the click of a button.

  12. #12


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339
    Quote Originally Posted by k-strider View Post
    we actually isntall proxypal (which is free) on our staff laptops and put the button next to the home button it simply enables and disables the proxy at the click of a button.
    The point of this is that you don't need to click a button, and it works cross platform on multiple browsers/phones etc

  13. #13


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,891
    Thank Post
    226
    Thanked 2,672 Times in 1,970 Posts
    Rep Power
    786
    This one works perfectly for me.

    Code:
    function FindProxyForURL(url,host)
    { if(isPlainHostName(host) || 
         isInNet(host,"10.12.92.0","255.255.252.0")) return "DIRECT"; 
       else return "PROXY 92.43.65.65:80; DIRECT";
    }

SHARE:
+ Post New Thread

Similar Threads

  1. WPAD File, Auto Detect Proxy Server
    By steveo2000 in forum Windows Server 2000/2003
    Replies: 6
    Last Post: 14th July 2010, 01:40 PM
  2. Stupid proxy pac
    By Oops_my_bad in forum Wireless Networks
    Replies: 10
    Last Post: 23rd March 2009, 09:59 AM
  3. Replies: 2
    Last Post: 29th April 2008, 03:17 PM
  4. Replies: 2
    Last Post: 23rd February 2008, 05:17 PM
  5. Creating a PAC file
    By u8dmtm in forum Coding
    Replies: 4
    Last Post: 2nd March 2006, 03:49 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •