How to configure Snow Leopard to use proxy server?

Discussion in 'Apple' started by DaveC, Mar 21, 2012.

  1. DaveC

    DaveC Guest

    I want to configure Snow Leopard to use a proxy server for a few web sites.

    It looks like if I configure it with a proxy server, that it defaults to
    using this server nearly always.

    Can I use OS X's proxy settings to use the proxy server based on URL
    patterns, rather than to NOT use proxy server based on URL patterns? In other
    words, can I make the default action to not use the proxy server, and to use
    the proxy if the URL is one of the few I specify?

    Thanks,
    Dave
    DaveC, Mar 21, 2012
    #1
    1. Advertising

  2. In article
    <-september.org>,
    DaveC <> wrote:

    > I want to configure Snow Leopard to use a proxy server for a few web sites.
    >
    > It looks like if I configure it with a proxy server, that it defaults to
    > using this server nearly always.
    >
    > Can I use OS X's proxy settings to use the proxy server based on URL
    > patterns, rather than to NOT use proxy server based on URL patterns? In other
    > words, can I make the default action to not use the proxy server, and to use
    > the proxy if the URL is one of the few I specify?


    You need to use a proxy.pac file. This is a file containing a
    JavaScript function that looks at the URL and decides whether to use a
    proxy or not.

    http://en.wikipedia.org/wiki/Proxy_auto-config

    --
    Barry Margolin,
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    Barry Margolin, Mar 21, 2012
    #2
    1. Advertising

  3. DaveC

    DaveC Guest

    > You need to use a proxy.pac file. This is a file containing a
    > JavaScript function that looks at the URL and decides whether to use a
    > proxy or not.
    >
    > http://en.wikipedia.org/wiki/Proxy_auto-config


    In what directory is this file to be placed?

    Thanks.
    DaveC, Mar 22, 2012
    #3
  4. DaveC

    Wes Groleau Guest

    On 03-22-2012 16:14, DaveC wrote:
    >> You need to use a proxy.pac file. This is a file containing a
    >> JavaScript function that looks at the URL and decides whether to use a
    >> proxy or not.
    >>
    >> http://en.wikipedia.org/wiki/Proxy_auto-config

    >
    > In what directory is this file to be placed?


    Maybe the one you specify in System Preferences -> Network -> Advanced
    -> Automatic Proxy config ?

    --
    Wes Groleau

    Nobody believes a theoretical analysis — except the guy who did it.
    Everybody believes an experimental analysis — except the guy who did it.
    — Unknown
    Wes Groleau, Mar 22, 2012
    #4
  5. DaveC

    DaveC Guest

    > Maybe the one you specify in System Preferences -> Network -> Advanced
    > -> Automatic Proxy config ?
    > [Wes G.]


    It allows you to place it anywhere. Where's a good folder to store it?

    Thanks.
    DaveC, Mar 23, 2012
    #5
  6. > You need to use a proxy.pac file. This is a file containing a
    > JavaScript function that looks at the URL and decides whether to use a
    > proxy or not.
    >
    > http://en.wikipedia.org/wiki/Proxy_auto-config


    It could be easier to just use a different web browser - use Safari for
    the "normal" websites and Firefox for the websites that need a proxy
    server.

    Helpful Harry :eek:)
    Helpful Harry, Mar 23, 2012
    #6
  7. DaveC

    Sparky Guest

    > It could be easier to just use a different web browser - use Safari for
    > the "normal" websites and Firefox for the websites that need a proxy
    > server.
    >
    > Helpful Harry :eek:)


    Man, I SO wanted to do this.

    I tried it (Safari & Firefox) but 2 browsers eat up HUGE memory and disk swap
    file space. My Mac slowed to a creep.

    Having more than one browser open eats up system resources that are best
    spent elsewhere...
    Sparky, Mar 23, 2012
    #7
  8. DaveC

    DaveC Guest

    > http://en.wikipedia.org/wiki/Proxy_auto-config

    Having a little trouble with the script language the proxy.pac file...

    Here's what I've copied & modified from examples on the above page:
    - - -
    function FindProxyForURL(url, host) {
    // URLs within the target domain are
    // accessed through the proxy server:
    if (shExpMatch(host, "http://www.bbc.co.uk*"))
    {
    return "PROXY 123.345.567.789:1234";
    }

    // All other requests don't use the proxy.
    return "DIRECT";
    }
    - - -
    If I comment out the "if" line and just return the proxy IP and port, all is
    well. (Oh, and also comment out the "return 'DIRECT' " line at the bottom.)

    But as it is (above) the proxy is not used. All web pages are loaded
    normally, just not using the proxy.

    It's probably bog simple, but I'm missing it.

    Thanks.
    DaveC, Mar 23, 2012
    #8
  9. DaveC

    DaveC Guest

    > If I comment out the "if" line and just return the proxy IP and port, all is
    > well. (Oh, and also comment out the "return 'DIRECT' " line at the bottom.)


    By "all is well" I mean that if these 2 lines are commented out, all http
    calls go through the proxy server.
    DaveC, Mar 23, 2012
    #9
  10. DaveC

    Alan Baker Guest

    In article
    <-september.org>,
    DaveC <> wrote:

    > > Maybe the one you specify in System Preferences -> Network -> Advanced
    > > -> Automatic Proxy config ?
    > > [Wes G.]

    >
    > It allows you to place it anywhere. Where's a good folder to store it?
    >
    > Thanks.


    No folder is any better than any other, really, but since it's
    essentially a preference you're setting up, why not store it in your
    Preferences folder?

    --
    Alan Baker
    Vancouver, British Columbia
    "If you raise the ceiling four feet, move the fireplace from that wall
    to that wall, you'll still only get the full stereophonic effect if you
    sit in the bottom of that cupboard."
    Alan Baker, Mar 23, 2012
    #10
  11. DaveC

    David Empson Guest

    DaveC <> wrote:

    > > http://en.wikipedia.org/wiki/Proxy_auto-config

    >
    > Having a little trouble with the script language the proxy.pac file...
    >
    > Here's what I've copied & modified from examples on the above page:
    > - - -
    > function FindProxyForURL(url, host) {
    > // URLs within the target domain are
    > // accessed through the proxy server:
    > if (shExpMatch(host, "http://www.bbc.co.uk*"))


    Try removing the "http://" prefix from the string. The host parameter is
    a domain name, not a URL.

    The example on the Wikipedia page has this:

    if (shExpMatch(host, "*.example.com"))

    This function uses Windows shell expression matching rules, thus '?'
    matches any single character, and '*' matches zero or more characters.

    I'm not sure whether the shExpMatch function is universally supported by
    PAC files, or if it is specific to Windows (and possibly just Internet
    Explorer). Some sources say its second parameter is a regular
    expression, so there may be conflicting implementations and you need to
    use the right one for your browser.

    Some of the links at the bottom of the page have more useful examples.
    e.g. <https://calomel.org/proxy_auto_config.html> uses this function:

    dnsDomainIs(host, ".domain.home")

    rather than shExpMatch. I expect dnsDomainIs doesn't allow wildcards but
    I'd need to do more research to confirm.

    The site http://www.proxypacfiles.com/ also looks useful from a quick
    glance.

    --
    David Empson
    David Empson, Mar 23, 2012
    #11
  12. DaveC

    DaveC Guest

    > Try removing the "http://" prefix from the string. The host parameter is
    > a domain name, not a URL.
    > ...
    > [David Empson]


    That was part of the solution. Here's the working script:
    - - -
    function FindProxyForURL(url, host) {

    // Pages within the target domain are accessed
    // through the FoxyProxy subscription server:

    if (host == "www.example.com") // NO HTTP PREFIX
    {
    return "PROXY 123.345.567.789:1234";
    }
    else
    {

    // All other requests don't use the proxy.

    return "DIRECT";
    }
    }
    - - -
    Thanks for the suggestions.
    DaveC, Mar 23, 2012
    #12
  13. DaveC

    David Stone Guest

    In article
    <-september.org>,
    Sparky <> wrote:

    > > It could be easier to just use a different web browser - use Safari for
    > > the "normal" websites and Firefox for the websites that need a proxy
    > > server.
    > >
    > > Helpful Harry :eek:)

    >
    > Man, I SO wanted to do this.
    >
    > I tried it (Safari & Firefox) but 2 browsers eat up HUGE memory and disk swap
    > file space. My Mac slowed to a creep.


    How ancient is your Mac? I have no problem with Safari, Firefox, Opera,
    Dreamweaver, Mail, and a bunch of other apps open at the same time - not
    even on my old G4 iBook...

    Incidentally, although it's been snipped here, you appeared to be
    trying to use a proxy to access the BBC web site. Just wondering why?
    David Stone, Mar 23, 2012
    #13
  14. DaveC

    David Sankey Guest

    In article
    <-september.org>,
    DaveC <> wrote:

    > > You need to use a proxy.pac file. This is a file containing a
    > > JavaScript function that looks at the URL and decides whether to use a
    > > proxy or not.
    > >
    > > http://en.wikipedia.org/wiki/Proxy_auto-config

    >
    > In what directory is this file to be placed?


    The choice is yours - you specify the location of the file...

    Create your configuration file.

    Then in Network Preferences, Advanced... button, select the Proxies tab
    and tick Automatic Proxy Configuration.

    If the configuration file is on the web you enter its URL. Otherwise
    you click the Choose File... button and navigate to your file.

    About the only gotchas are:

    i) if file is on the web, it needs to be reachable without going via a
    proxy!
    ii) if the file is local and it's a multiuser machine, the file needs
    to be readable by all users...

    Kind regards,

    Dave
    David Sankey, Mar 23, 2012
    #14
  15. DaveC

    David Sankey Guest

    In article
    <-september.org>,
    DaveC <> wrote:

    > I want to configure Snow Leopard to use a proxy server for a few web sites.
    >
    > It looks like if I configure it with a proxy server, that it defaults to
    > using this server nearly always.
    >
    > Can I use OS X's proxy settings to use the proxy server based on URL
    > patterns, rather than to NOT use proxy server based on URL patterns? In other
    > words, can I make the default action to not use the proxy server, and to use
    > the proxy if the URL is one of the few I specify?


    An alternative to using your own proxy.pac is to go with Firefox and use
    the foxyproxy add-on.

    Dave
    David Sankey, Mar 23, 2012
    #15
  16. DaveC

    Warren Oates Guest

    In article
    <-september.org>,
    DaveC <> wrote:

    > > http://en.wikipedia.org/wiki/Proxy_auto-config

    >
    > Having a little trouble with the script language the proxy.pac file...
    >
    > Here's what I've copied & modified from examples on the above page:
    > - - -
    > function FindProxyForURL(url, host) {
    > // URLs within the target domain are
    > // accessed through the proxy server:
    > if (shExpMatch(host, "http://www.bbc.co.uk*"))
    > {
    > return "PROXY 123.345.567.789:1234";
    > }
    >
    > // All other requests don't use the proxy.
    > return "DIRECT";
    > }
    > - - -
    > If I comment out the "if" line and just return the proxy IP and port, all is
    > well. (Oh, and also comment out the "return 'DIRECT' " line at the bottom.)
    >
    > But as it is (above) the proxy is not used. All web pages are loaded
    > normally, just not using the proxy.
    >
    > It's probably bog simple, but I'm missing it.
    >
    > Thanks.


    You're trying to get the Beeb from abroad? I pay Witopia for that.
    --

    .... do not cover a warm kettle or your stock may sour. -- Julia Child
    Warren Oates, Mar 23, 2012
    #16
  17. DaveC

    DaveC Guest

    > Incidentally, although it's been snipped here, you appeared to be
    > trying to use a proxy to access the BBC web site. Just wondering why?


    One may not like Brit TV, but I like to watch some of the documentaries and
    such archived there. Once in a while they have a decent (American!) film
    available. These aren't available unless you're using a proxy or such...

    Dave
    DaveC, Mar 23, 2012
    #17
  18. DaveC

    DaveC Guest

    > How ancient is your Mac? I have no problem with Safari, Firefox, Opera,
    > Dreamweaver, Mail, and a bunch of other apps open at the same time - not
    > even on my old G4 iBook...


    2011 mini 2.7 GHz i7, OS X 10.6 (yes 10.6).
    DaveC, Mar 23, 2012
    #18
  19. DaveC

    DaveC Guest

    > You're trying to get the Beeb from abroad? I pay Witopia for that.
    > [Warren O.]


    You probably can watch all the archived iPlayer content. I'm curious: can you
    watch any of the "Watch Live" content on the site?

    Dave
    DaveC, Mar 23, 2012
    #19
  20. DaveC

    DaveC Guest

    > An alternative to using your own proxy.pac is to go with Firefox and use
    > the foxyproxy add-on.
    >
    > Dave


    I did that for quite a long while. FP is a great little add-on.

    But I was having issues with how some web pages were loading. Don't know what
    the issues were, but I tried Safari and voila!

    Also, FF uses quite a lot of system resources. With Safari, pages load ¡NOW!,
    which wasnt' my experience with FF. It's quite a remarkable improvement, one
    that will keep me from trying FF again anytime soon.

    YMMV...

    And once the proxy script was working, it's quite cool to know "I made
    that!".

    Dave (the other)
    DaveC, Mar 23, 2012
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Richard Maine

    Re: Test of Leopard vs. Snow Leopard

    Richard Maine, Oct 6, 2009, in forum: Apple
    Replies:
    0
    Views:
    332
    Richard Maine
    Oct 6, 2009
  2. MC
    Replies:
    4
    Views:
    379
    Priam
    Oct 7, 2009
  3. Replies:
    2
    Views:
    360
    Richard Maine
    Oct 6, 2009
  4. James Sidbury
    Replies:
    4
    Views:
    353
    P. Sture
    Oct 14, 2009
  5. Nick Naym

    Snow Leopard vs. Leopard

    Nick Naym, Nov 11, 2009, in forum: Apple
    Replies:
    8
    Views:
    314
    David Fritzinger
    Nov 12, 2009
Loading...

Share This Page