cancel
Showing results for 
Search instead for 
Did you mean: 

Proxy Pac

Marco_113
Frequent Advisor

Proxy Pac

Hi all i've a problem with proxy.pac squid.

My file is very easy but it does not work:

function FindProxyForURL(url, host)
{
if (isInNet(myIpAddress(),"172.22.24.0","255.255.255.0"))
return "PROXY 172.22.24.10:8080";
else
return "DIRECT";
}

Can anyone help me
Thanks
2 REPLIES
Matti_Kurkela
Honored Contributor

Re: Proxy Pac

It's been a very long time since I did these things, but I would have written it like this:

function FindProxyForURL(url, host)
{
if (isInNet(myIpAddress(), "172.22.24.0", "255.255.255.0")) {
return "PROXY 172.22.24.10:8080";
}
else {
return "DIRECT";
}
}

I am not 100% sure, but I seem to recall that the if...else structure was rather finicky about having the "extra" curly braces in there.

Note that this file is not related to the squid proxy itself at all: it's for configuring the web browsers, to make them use the proxy automatically when necessary.
You must place this file on some web server (not necessarily the proxy machine itself) so that the browsers can access it, and the web server must be configured to inform the browser that the MIME type of the .pac file is "application/x-ns-proxy-autoconfig".

You can use "lynx --dump --head " to verify that the MIME type of the file is configured correctly.

MK
MK
Marco_113
Frequent Advisor

Re: Proxy Pac

Hi and thanls for reply,
my proxy.pac is

function FindProxyForURL(url, host)
{
if (isInNet(myIpAddress(), "172.22.24.0", "255.255.255.0"))
return "PROXY 172.22.24.10:8080";
else
return "DIRECT";
}

It works correctly under my web server apache.

The lynx command results:

HTTP/1.1 200 OK
Date: Tue, 20 May 2008 10:05:35 GMT
Server: Apache/2.2.3 (Red Hat)
Last-Modified: Tue, 20 May 2008 10:02:13 GMT
ETag: "be525e-9c-92fff340"
Accept-Ranges: bytes
Content-Length: 156
Connection: close
Content-Type: application/x-ns-proxy-autoconfig