wiki:Proxies

Version 2 (modified by speck, 11 years ago) (diff)

--

Proxies

GlimmerBlocker is itself an http proxy and it supports forwarding the requests to other proxies in addition to contacting the web-servers directly.

Case 1: No proxy

This is by far the most comment case. GlimmerBlocker always contacts the web servers directly.

Case 2: Using a single proxy

This is the case when you e.g. have a work computer which you never bring home and the company requires use of a proxy. GlimmerBlocker will always use this proxy.

Case 3: Location-dependent proxy setup

Suppose you have a MacBook which you bring to work. At work it must use a company-wide proxy, but at home it must contact the servers directly. You can write a small Javascript (see examples below) which determines which proxy (if any) that should be used by examining the Network Location, AirPort network name and/or ip-adresses.

Case 4: URL-dependent proxy setup

This is the most advanced case. In addition to case 3, you can create rules for specific hosts, so accessing some hosts will use one proxy, other hosts will use another proxy, and the remaining some other proxy. Just like you can block ads using host/path/query criterias, you can specify a request-specific proxy.

How to configure

Select the "Network" tab in the GlimmerBlocker Preferences Pane. To never use a proxy (case 1), select "None". To always use the same proxy (case 2), select "Always use this proxy" and enter the name and port-number of the proxy. To use location-dependent proxy (case 3), select "Dynamic configuration".

URL-dependent proxies (case 4) are created as rules, and matching rules overrides any proxy which is setup in the "Network" tab.

The proxy Javascript

The dynamic configurations are created by writing a small Javascript which sets the proxy variable. Select "Dynamic configuration" and click the "edit" button. The edit sheet has two tabs: the first one for editing the script, and the second shows the current configuration globals as a JSON dump:

Short JSON example:

gb.network = {
   location: {
      name: 'At work'
   },
   interfaces: {
      en0: {},
      en1: {
         AirPort: {
            power: 1,
            ssid: 'The Great Company',
         },
         IPv4: {
            addr: ['10.0.1.123'],
            mask: ['255.255.255.0'],
            broadcast: ['10.0.0.255']
         }
      }
   }
}

The script specifies the proxy by assigning it to the gb.proxy variable. An empty string or null value means "use no proxy". The variable will be empty when the script is executed, so if the script doesn't assign any value to the variable, no proxy is used. It does not 'remember' the last assignment.

Simple "At work" location

Suppose you must use a proxy when having selected the "At work" location, but not when using "Automatic" or "At home". The simple script is:

#!
if (network.location.name == 'At work')
  gb.proxy = 'proxy.company.com:8008';

Beware: The above comparison is case-sensitive, so you might want to use network.location.name.toLowerCase() == 'at work'. Make sure you have the exact name and doesn't have extra spaces in the location name.

Attachments (7)

Download all attachments as: .zip