Quantcast
Channel: Configuration & Scripting
Viewing all articles
Browse latest Browse all 780

PAC File - IIS - Redirection to a custom error page

$
0
0
<div> <div>

Hi Everyone,

I am trying to redirect unwanted HTTPS URLs to a proxy and display a custom error page.

The big picture is to display an error page in the browser if an unwanted URL is entered in the Address bar or browsed.

Everything runs locally on the same machine, IIS and the browser (IE).

First, my pac file is served by an IIS10 Website bound on port 80 to the clients.

Second, in my pac file i check a few URL with dnsDomainIs and if the domain match it goes directly on Internet.

Third, in my pac file, if the domain does not match it redirect to another website running on the same IIS bound on another port to display a specific webpage.

My IIS sites are like this:

</div> </div>
  • Pac File (Default site): Binding type: HTTP, Hostname: {empty}, port: 80, ip address: *  (to serve the PAC file)
  • Error Page: (to serve the error page)
    • Binding type: HTTP, Hostname: {empty}, port: 8080, ip address: * 
    • binding type: HTTPS, Hostname: {empty}, port: 443, ip address: * 

So Far:

  • Any unwanted HTTP URL is redirected to the error page -> Good
  • Any unwanted HTTPS URL , the browsers display "This page cannot be displayed"
  • When I enter https://localhost the browser displays "There is a problem with this website certificate..." as it is a self signed certificate

I would say everything is running so far except when, on the browser, I try to see if https://www.google.com is redirected to the proxy (website) and the browser displays the custom webpage, but nada :-/ it displays the message "This page Cannot be displayed".

I have used those rules in my pac: (note that www.hp.com is an example)

function FindProxyForURL(url, host) {
 if (dnsDomainIs(host, "www.hp.com")) { return "DIRECT"; }

 // every other http: URLs will redirect to the localhost:8080 to display an error page
if (url.substring(0,5)=="http:" ) { return "PROXY localhost:8080"; }

// below the rest like https should be redirected to the localhost:443
else { return "PROXY localhost:443"; } }

For every website with URL starting like https://onedrive.live.com/about/en-us/ it seems not to be redirected through the localhost:443 and the client browser does display "the page cannot be found" and not my custom page.

I was wondering if rewriting URL HTTPS to HTTP or redirecting all pages to my error page with URL rewrite module in IIS would work.

Any help very appreciated, I am out of ideas,

Thanks a lot.


Viewing all articles
Browse latest Browse all 780

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>