Using proxy.pac to access Apache 2 with a hostname?
- by leeand00
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:
From the menubar selecting "Edit-Preferences"
In the resulting "Firefox Preferences" window clicking the "Advanced" tab.
Clicking the "Network" tab
Clicking the "Settings" button.
Selecting the "Automatic proxy configuration URL:" radio button.
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/ ?