Archive for July, 2007

Automatically Configure Browsers for Proxy

0

Autoconfigure Scripts for Proxy Settings – Apr. 22, 2004

April 22, 2004: Added more complex examples to bypass proxy for multiple URL’s.

August 15, 2003: Updated with example of bypassing proxy for a particular URL, and also mention WPAD.DAT to automatically configure Internet Explorer.

PROXY.PAC Files

Several of my clients have asked for a way to have browsers automatically pick up proxy settings if the PC (usually a laptop) is on the local LAN, but not use a proxy server if the PC is not on the local LAN. For instance, moving a laptop from a home network with no proxy server to the office LAN, with a BorderManager server.

The browser can be configured with a simple PROXY.PAC file. The PROXY.PAC file can be quite complex, providing for load-balancing, fault tolerance, or other uses. I would be happy to produce a custom proxy.pac file for you (as a paid consulting project). The examples here are pretty basic.

I have tested this PROXY.PAC file on Netscape, Mozilla, Firefox, Opera and Internet Explorer on Windows XP Professional and Windows 2000 Professional.

Note: This is not a method for remotely or permanently setting the proxy settings, which can be done in a number of ways (ZENworks, login script, proxy configuration files from Netscape or Microsoft, etc.) I will assume that you will visit the workstations and enter the proxy settings as necessary to point to the PROXY.PAC file. If the PC is to be moved off the local LAN, you will also need to copy the file to the PC.

How it works:

The .PAC file checks the local IP subnet address of the PC, and branches with an IF / ELSE statement. If the PC is located in a subnet that matches, a proxy server is used. If the PC is on any other subnet, a direct connection is used instead of the proxy.

function FindProxyForURL(url, host)
{
if (isInNet(myIpAddress(), “192.168.1.0″, “255.255.255.0″))
return “PROXY 192.168.1.1:8080″;
else
return “DIRECT”;
}

In my example file #1, I check that the host is in the 192.168.1.0 (255.255.255.0) subnet. If it is, I tell the browser to use a proxy at IP address 192.168.1.1, using port 8080. Obviously, you may need to change the subnet, subnet mask and proxy address/port for your LAN configuration.

There are methods which can be used to check for multiple subnets in case you have more than one internal LAN subnet. Ask in the Novell Public Forums about more complex PROXY.PAC files. (Or hire me to develop one for your environment!)

Download my example PROXY.PAC file #1 HERE (simple version)

More Complex Version

I have had a number of occasions where I needed to bypass the http proxy for a particular web site. This is easily done with a PROXY.PAC file, by putting in an IF statement with the proper syntax. (You can have lots of IF statements if you want to do this for multiple web sites.)

Here is an example that bypasses proxy for a particular web site (principia.mo.techpaths.com) that was giving grief when going to it through the HTTP Proxy:

function FindProxyForURL(url, host)
{
if (shExpMatch(url, “http://principia.mo.techpaths.com*”)) {
return “DIRECT”;
}
if (isInNet(myIpAddress(), “192.168.1.0″, “255.255.255.0″))
return “PROXY 192.168.1.1:8080″;
else
return “DIRECT”;
}

You can download this version of PROXY.PAC here.

Slightly More Complex PROXY.PAC Example – Multiple Proxy Bypass URL’s (not for laptops)

In this example you can add multiple URL’s to NOT use a proxy, and then proxy everything else. In this example, you do not have a check for the local network, so it would not be a good example for a laptop that moves between networks.

function FindProxyForURL(url, host)
{
// variable strings to return
var proxy_yes = “PROXY 192.168.1.1:8080″;
var proxy_no = “DIRECT”;
if (shExpMatch(url, “http://www.mycompanywebsite.com*”)) { return proxy_no; }
if (shExpMatch(url, “http://www.myotherwebsite.com*”)) { return proxy_no; }
if (shExpMatch(url, “http://www.my3rdlocalsite.com*”)) { return proxy_no; }
// Proxy anything else
return proxy_yes;
}

Even More Complex PROXY.PAC Example – Multiple Proxy Bypass URL’s with Local Address Check

In this example you can add multiple URL’s to NOT use a proxy, and then proxy everything else. In this example, you have a check for the local network, so you can use this one on a laptop.

function FindProxyForURL(url, host)
{
// variable strings to return
var proxy_yes = “PROXY 192.168.1.1:8080″;
var proxy_no = “DIRECT”;
if (shExpMatch(url, “http://www.mycompanywebsite.com*”)) { return proxy_no; }
if (shExpMatch(url, “http://www.myotherwebsite.com*”)) { return proxy_no; }
if (shExpMatch(url, “http://www.my3rdlocalsite.com*”)) { return proxy_no; }
if (shExpMatch(url, “http://192.168.1.100*”)) { return proxy_no; }
// Proxy if PC is on local LAN
if (isInNet(myIpAddress(), “192.168.1.0″, “255.255.255.0″))
return “PROXY 192.168.1.1:8080″;
else
return “DIRECT”;
}

Autoconfigure the Proxy Settings from the BorderManager Server (for Internet Explorer)

In this method, you point to a file being made available via the BorderManager miniwebserver. For a simple PROXY.PAC file and a PC that says on the local LAN, this doesn’t make a lot of sense, as it is easier to just enter the proxy server address and port numbers. However, this technique is useful when you have complex PROXY.PAC files which do load balancing, etc.

1. Copy the PROXY.PAC file to the BorderManager SYS:ETC\PROXY\DATA directory.
2. In the browser proxy settings, configure the Automatic Proxy Configuration (Netscape) or Use Automatic Configuration Script (IE) URL to:

http://192.168.1.1:1959/data/proxy.pac

Where 192.168.1.1 must be changed to your BorderManager server’s private IP address. The port 1959 is the default miniwebserver address.

If Internet Explorer doesn’t see the file, it will default to using whatever proxy settings are configured under LAN settings.

Certain versions of Internet Explorer have a bug with .PAC files. This can be fixed with a patch. See the Microsoft article here.

Autoconfigure the Proxy Settings from a Local Copy of the PROXY.PAC File (IE or Netscape)

In this method, useful for laptops that travel on and off your LAN, you copy the file to some local directory, and point to it.

1. Copy the PROXY.PAC file to the C:\WINDOWS directory, or other directory of your choice.
2. In the browser proxy settings, configure the Automatic Proxy Configuration (Netscape) or Use Automatic Configuration Script (IE) URL to:

Netscape, use: file:///c|/windows/proxy.pac
Internet Explorer, use: file://c:/windows/proxy.pac

In Netscape, click on the Reload button.

Have Internet Explorer Automatically Configure Itself to Use a Proxy

There are ways to push the proxy settings (including PROXY.PAC) files to any browser, but Internet Explorere tends to be the easiest. In fact, you can have Internet Explorer automatically discover your PROXY.PAC file without you even having to touch the browser, if the browser is left at default settings. This is done by renaming PROXY.PAC to WPAD.DAT, and launching it from web server, using a local DNS entry. Please see this tip on methods for configuring browsers to pick up proxy settings.

 

from http://nscsysop.hypermart.net/proxypac.html

Ruby on Rails

0

Something weird with this kind of programming…
in this programming language we can’t read the code partially, we must know how the code flow. in Rails we will find concept of MVC (Models,Views n Controller) something like ASP.NET have.. in this concept we just create the model, decide how it will displayed on web browser and controlling it’s behavior when it’s communicate with the database server or something like event driven.

first sight, because of my basic web programming which develop the web application using function based method, i found a few problem when implemmentating a web application using rails framework. some idea how to learn the framework is read step by step from the idiots guide and practice it on it’s environment.

before we can develop it, we need the suitable environment. because the minimality of resource n net connection, some problem arise when set up the development environment in first time. but with the magically n the power of LINUX and all my kungfu, the development environment and the server can be setup.

first thing to do with the power of rails n ruby, we can use the scaffold function from rails to generate form from the table in the database server. with the controller we can validate every data which will be inserted to database.

now… there are something to do to get familiar with this environment. hopefully there many people who can help me to explain n solve  every problems.

thanks to ruby n the rails framework..

Go to Top