I want to set up a fake proxy server that returns a fixed HTML page directly (same page for all requests) rather than actually proxying.

Use case: Users need to update the PAC file URL in their web browsers, so I want to show a message to users using the old PAC URL.

I can't find a way to do this using the Apache proxy modules or a CGI script. Example of trying to do this with a CGI script:


function FindProxyForURL ( url, host ) {
    return "PROXY";


ScriptAlias / /data/www/pac-warning/cgi-bin/nph-warn/


#!/usr/bin/perl -T
print "$ENV{SERVER_PROTOCOL} 200 OK\n";
print "Content-type: text/html\n\n";
print "<html>...HTML page here...</html>\n";

This CGI script is incorrect, as it is being called for an HTTP "CONNECT" method but is responding as if this is a normal web request. How can I fake the CONNECT method and return an immediate HTML response?

  • I have used PAC files to point various domains to my local server for the purpose of blocking ads. That was before the AdBlock extension was available. At the time, it worked fine. I didn't need to implement HTTP Connect. – Stephen Ostermiller Jan 6 '17 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.