<s>
A	O
proxy	B-Protocol
auto-config	I-Protocol
(	O
PAC	O
)	O
file	O
defines	O
how	O
web	B-Application
browsers	I-Application
and	O
other	O
user	B-Protocol
agents	I-Protocol
can	O
automatically	O
choose	O
the	O
appropriate	O
proxy	B-Application
server	I-Application
(	O
access	O
method	O
)	O
for	O
fetching	O
a	O
given	O
URL	O
.	O
</s>
<s>
A	O
PAC	B-Protocol
file	I-Protocol
contains	O
a	O
JavaScript	B-Language
function	O
FindProxyForURL(url, host )	O
.	O
</s>
<s>
These	O
specifications	O
cause	O
the	O
user	B-Protocol
agent	I-Protocol
to	O
use	O
a	O
particular	O
proxy	B-Application
server	I-Application
or	O
to	O
connect	O
directly	O
.	O
</s>
<s>
The	O
browser	B-Application
fetches	O
this	O
PAC	B-Protocol
file	I-Protocol
before	O
requesting	O
other	O
URLs	O
.	O
</s>
<s>
The	O
URL	O
of	O
the	O
PAC	B-Protocol
file	I-Protocol
is	O
either	O
configured	O
manually	O
or	O
determined	O
automatically	O
by	O
the	O
Web	B-Protocol
Proxy	I-Protocol
Auto-Discovery	I-Protocol
Protocol	I-Protocol
.	O
</s>
<s>
Modern	O
web	B-Application
browsers	I-Application
implement	O
several	O
levels	O
of	O
automation	O
;	O
users	O
can	O
choose	O
the	O
level	O
that	O
is	O
appropriate	O
to	O
their	O
needs	O
.	O
</s>
<s>
Automatic	O
proxy	O
selection	O
:	O
Specify	O
a	O
host-name	O
and	O
a	O
port	B-Protocol
number	I-Protocol
to	O
be	O
used	O
for	O
all	O
URLs	O
.	O
</s>
<s>
Most	O
browsers	B-Application
allow	O
you	O
to	O
specify	O
a	O
list	O
of	O
domains	O
(	O
such	O
as	O
localhost	O
)	O
that	O
will	O
bypass	O
this	O
proxy	O
.	O
</s>
<s>
Proxy	O
auto-configuration	O
(	O
PAC	O
)	O
:	O
Specify	O
the	O
URL	O
for	O
a	O
PAC	B-Protocol
file	I-Protocol
with	O
a	O
JavaScript	B-Language
function	O
that	O
determines	O
the	O
appropriate	O
proxy	O
for	O
each	O
URL	O
.	O
</s>
<s>
Web	B-Protocol
Proxy	I-Protocol
Auto-Discovery	I-Protocol
Protocol	I-Protocol
(	O
WPAD	B-Protocol
)	O
:	O
Let	O
the	O
browser	B-Application
guess	O
the	O
location	O
of	O
the	O
PAC	B-Protocol
file	I-Protocol
through	O
DHCP	B-Protocol
and	O
DNS	B-Protocol
lookups	O
.	O
</s>
<s>
The	O
Proxy	B-Protocol
auto-config	I-Protocol
file	O
format	O
was	O
originally	O
designed	O
by	O
Netscape	B-Protocol
in	O
1996	O
for	O
the	O
Netscape	B-Protocol
Navigator	I-Protocol
2.0	I-Protocol
and	O
is	O
a	O
text	B-General_Concept
file	I-General_Concept
that	O
defines	O
at	O
least	O
one	O
JavaScript	B-Language
function	O
.	O
</s>
<s>
By	O
convention	O
,	O
the	O
PAC	B-Protocol
file	I-Protocol
is	O
normally	O
named	O
proxy.pac	B-Protocol
.	O
</s>
<s>
The	O
WPAD	B-Protocol
standard	I-Protocol
uses	O
wpad.dat	B-Protocol
.	O
</s>
<s>
To	O
use	O
it	O
,	O
a	O
PAC	B-Protocol
file	I-Protocol
is	O
published	O
to	O
a	O
HTTP	B-Application
server	I-Application
,	O
and	O
client	O
user	B-Protocol
agents	I-Protocol
are	O
instructed	O
to	O
use	O
it	O
,	O
either	O
by	O
entering	O
the	O
URL	O
in	O
the	O
proxy	O
connection	O
settings	O
of	O
the	O
browser	B-Application
or	O
through	O
the	O
use	O
of	O
the	O
WPAD	B-Protocol
protocol	O
.	O
</s>
<s>
The	O
URL	O
may	O
also	O
reference	O
a	O
local	O
file	O
as	O
for	O
example	O
:	O
file:///etc/proxy.pac	O
.	O
</s>
<s>
Even	O
though	O
most	O
clients	O
will	O
process	O
the	O
script	O
regardless	O
of	O
the	O
MIME	B-Application
type	I-Application
returned	O
in	O
the	O
HTTP	O
reply	O
,	O
for	O
the	O
sake	O
of	O
completeness	O
and	O
to	O
maximize	O
compatibility	O
,	O
the	O
HTTP	B-Application
server	I-Application
should	O
be	O
configured	O
to	O
declare	O
the	O
MIME	B-Application
type	I-Application
of	O
this	O
file	O
to	O
be	O
either	O
application/x	O
-ns-proxy-autoconfig	O
or	O
application/x	O
-javascript-config	O
.	O
</s>
<s>
There	O
is	O
little	O
evidence	O
to	O
favor	O
the	O
use	O
of	O
one	O
MIME	B-Application
type	I-Application
over	O
the	O
other	O
.	O
</s>
<s>
It	O
would	O
be	O
,	O
however	O
,	O
reasonable	O
to	O
assume	O
that	O
application/x	O
-ns-proxy-autoconfig	O
will	O
be	O
supported	O
in	O
more	O
clients	O
than	O
application/x	O
-javascript-config	O
as	O
it	O
was	O
defined	O
in	O
the	O
original	O
Netscape	B-Protocol
specification	O
,	O
the	O
latter	O
type	O
coming	O
into	O
use	O
more	O
recently	O
.	O
</s>
<s>
A	O
very	O
simple	O
example	O
of	O
a	O
PAC	B-Protocol
file	I-Protocol
is	O
:	O
</s>
<s>
This	O
function	O
instructs	O
the	O
browser	B-Application
to	O
retrieve	O
all	O
pages	O
through	O
the	O
proxy	O
on	O
port	B-Protocol
8080	I-Protocol
of	O
the	O
server	O
proxy.example.com	O
.	O
</s>
<s>
Should	O
this	O
proxy	O
fail	O
to	O
respond	O
,	O
the	O
browser	B-Application
contacts	O
the	O
Web-site	O
directly	O
,	O
without	O
using	O
a	O
proxy	O
.	O
</s>
<s>
The	O
latter	O
may	O
fail	O
if	O
firewalls	B-Application
,	O
or	O
other	O
intermediary	O
network	O
devices	O
,	O
reject	O
requests	O
from	O
sources	O
other	O
than	O
the	O
proxy	O
—	O
a	O
common	O
configuration	O
in	O
corporate	O
networks	O
.	O
</s>
<s>
A	O
more	O
complicated	O
example	O
demonstrates	O
some	O
available	O
JavaScript	B-Language
functions	O
to	O
be	O
used	O
in	O
the	O
FindProxyForURL	O
function	O
:	O
</s>
<s>
SOCKS	B-Application
Use	O
a	O
SOCKS	B-Application
proxy	I-Application
.	O
</s>
<s>
HTTP	O
,	O
HTTPS	O
Introduced	O
in	O
more	O
recent	O
versions	O
of	O
Firefox	B-Application
.	O
</s>
<s>
SOCKS4	B-Application
,	O
SOCKS5	B-Application
Introduced	O
in	O
more	O
recent	O
versions	O
of	O
Firefox	B-Application
.	O
</s>
<s>
Specifies	O
the	O
SOCKS	B-Application
protocol	O
version	O
.	O
</s>
<s>
The	O
encoding	O
of	O
PAC	O
scripts	O
is	O
generally	O
unspecified	O
,	O
and	O
different	O
browsers	B-Application
and	O
network	O
stacks	O
have	O
different	O
rules	O
for	O
how	O
PAC	O
scripts	O
may	O
be	O
encoded	O
.	O
</s>
<s>
In	O
general	O
,	O
wholly	O
ASCII	B-Protocol
PAC	O
scripts	O
will	O
work	O
with	O
any	O
browser	B-Application
or	O
network	O
stack	O
.	O
</s>
<s>
Mozilla	B-Application
Firefox	I-Application
66	O
and	O
later	O
additionally	O
supports	O
PAC	O
scripts	O
encoded	O
as	O
UTF-8	O
.	O
</s>
<s>
The	O
function	O
dnsResolve	O
(	O
and	O
similar	O
other	O
functions	O
)	O
performs	O
a	O
DNS	B-Protocol
lookup	O
that	O
can	O
block	O
the	O
browser	B-Application
for	O
a	O
long	O
time	O
if	O
the	O
DNS	B-Protocol
server	O
does	O
not	O
respond	O
.	O
</s>
<s>
127.0.0.1	O
,	O
the	O
IP	B-Protocol
address	I-Protocol
of	O
the	O
localhost	O
.	O
</s>
<s>
In	O
2013	O
,	O
researchers	O
began	O
warning	O
about	O
the	O
security	O
risks	O
of	O
proxy	B-Protocol
auto-config	I-Protocol
.	O
</s>
<s>
The	O
threat	O
involves	O
using	O
a	O
PAC	O
,	O
discovered	O
automatically	O
by	O
the	O
system	O
,	O
to	O
redirect	O
the	O
victim	O
's	O
browser	B-Application
traffic	O
to	O
an	O
attacker-controlled	O
server	O
instead	O
.	O
</s>
<s>
Another	O
issues	O
about	O
pac	B-Protocol
file	I-Protocol
is	O
the	O
typical	O
implementation	O
involve	O
clear	O
text	O
http	O
retrieval	O
,	O
which	O
does	O
not	O
include	O
any	O
security	O
features	O
such	O
as	O
code	O
signing	O
or	O
web	O
certificates	O
.	O
</s>
<s>
Caching	O
of	O
proxy	O
auto-configuration	O
results	O
by	O
domain	O
name	O
in	O
Microsoft	O
's	O
Internet	B-Application
Explorer	I-Application
5.5	O
or	O
newer	O
limits	O
the	O
flexibility	O
of	O
the	O
PAC	O
standard	O
.	O
</s>
<s>
Alternatively	O
,	O
you	O
need	O
to	O
disable	O
caching	O
of	O
proxy	O
auto-configuration	O
results	O
by	O
editing	O
the	O
registry	B-Protocol
,	O
a	O
process	O
described	O
by	O
de	O
Boyne	O
Pollard	O
(	O
listed	O
in	O
further	O
reading	O
)	O
.	O
</s>
<s>
It	O
is	O
recommended	O
to	O
always	O
use	O
IP	B-Protocol
addresses	I-Protocol
instead	O
of	O
host	O
domain	O
names	O
in	O
the	O
isInNet	O
function	O
for	O
compatibility	O
with	O
other	O
Windows	O
components	O
which	O
make	O
use	O
of	O
the	O
Internet	B-Application
Explorer	I-Application
PAC	O
configuration	O
,	O
such	O
as	O
.NET	B-Application
2.0	I-Application
Framework	I-Application
.	O
</s>
<s>
The	O
current	O
convention	O
is	O
to	O
fail	O
over	O
to	O
direct	O
connection	O
when	O
a	O
PAC	B-Protocol
file	I-Protocol
is	O
unavailable	O
.	O
</s>
<s>
when	O
entering	O
or	O
leaving	O
a	O
VPN	O
)	O
,	O
dnsResolve	O
may	O
give	O
outdated	O
results	O
due	O
to	O
DNS	B-Protocol
caching	O
.	O
</s>
<s>
For	O
instance	O
,	O
Firefox	B-Application
usually	O
keeps	O
20	O
domain	O
entries	O
cached	O
for	O
60	O
seconds	O
.	O
</s>
<s>
Flushing	O
the	O
system	O
's	O
DNS	B-Protocol
cache	O
may	O
also	O
help	O
,	O
which	O
can	O
be	O
achieved	O
e.g.	O
</s>
<s>
in	O
Linux	O
with	O
sudo	O
service	O
dns-clean	O
start	O
or	O
in	O
Windows	O
with	O
ipconfig	O
/flushdns	O
.	O
</s>
<s>
Further	O
limitations	O
are	O
related	O
to	O
the	O
JavaScript	B-Language
engine	I-Language
on	O
the	O
local	O
machine	O
.	O
</s>
<s>
More	O
advanced	O
PAC	B-Protocol
files	I-Protocol
can	O
reduce	O
load	O
on	O
proxies	O
,	O
perform	O
load	O
balancing	O
,	O
fail	O
over	O
,	O
or	O
even	O
black/white	O
listing	O
before	O
the	O
request	O
is	O
sent	O
through	O
the	O
network	O
.	O
</s>
