Using proxy.pac to access Apache 2 with a hostname?

Posted by leeand00 on Server Fault See other posts from Server Fault or by leeand00
Published on 2011-01-10T06:24:55Z Indexed on 2011/01/10 6:55 UTC
Read the original article Hit count: 332

Filed under:
|
|
|

Note that I do not have a DNS on my network, and that is why I am resorting to using a proxy.pac file. I would like to be able to access my development Apache 2 server using a name instead of an ip without setting up a full blown DNS.

I am aware of setting names in the C:\Windows\System32\drivers\etc\hosts file and the /etc/hosts files, however I cannot edit the hosts file on all of the devices that I am testing the site on.

I've added a proxy.pac file to my Apache2 server and pointed my browsers settings to it at:

http://192.168.2.221/proxyutils/proxy.pac

...where 192.168.2.221 is thehostname's ip address.

I set the above URL in Firefox in the following manner:

  1. From the menubar selecting "Edit->Preferences"
  2. In the resulting "Firefox Preferences" window clicking the "Advanced" tab.
  3. Clicking the "Network" tab
  4. Clicking the "Settings" button.
  5. Selecting the "Automatic proxy configuration URL:" radio button.
  6. Entering http://192.168.2.221/proxyutils/proxy.pac and pressing OK.

The contents of the proxy.pac file on the Apache server

function FindProxyForURL(url, host) {
  if( dnsDomainIs(host, "thehostname") )
    return "PROXY 192.168.2.221:80";

  return "DIRECT";
}

In Firefox I then access the following URL: http://thehostname/wp-blog/

And instead of the development version of the Wordpress blog I am trying to access I get a URL of http://thehostnamehttp/thehostname/wp-blog/ in my address bar and a 404 Not Found page in the browser window.

Looking over proxy.pac, it seems like calling dnsDomainIs shouldn't work considering I don't have a DNS setup on my network, but I've also tried just comparing the host argument with the string "hostname" and it yielded the same result, even after modifying the proxy.pac file and clicking the reload button near the proxy settings.

This could also be a Wordpress problem, since I've noticed that directories without Wordpress seem to function perfectly normally. (see cross post here)

Is there any way I can modify my configuration so that I can access the site using http://thehostname/wp-blog/ ?

© Server Fault or respective owner

Related posts about apache2

Related posts about hostname