Link to home
Start Free TrialLog in
Avatar of Lewis Robertson
Lewis Robertson

asked on

Issue serving proxy.pac file as a webpage through IIS7.

Hello all,

I've spent so many hours on this now and can't figure it out.

I've created a really basic proxy.pac file, published as a website in IIS7.

Chrome and Firefox show the contents of the pac file within the browser as plain text, this is good.

But Internet Explorer always tries to download the file when I go to the URL!

It's driving my crazy trying to figure this out!


Only specific changes I've made in IIS7 are...

- MIME type (.pac) = application/x-ns-proxy-autoconfig

- HTTP response header (Content-Type) = text/plain


I am an amateur at IIS, been working in IT for 13 years but first time looking at this stuff.

First time I've ever had to post anything technical on a forum because I'm completely stumped.

I'm sure it's going to be one simple setting somewhere that I've missed, But I must have clicked on every Google result ever trying to find the answer!

Screenshots attached.


Please help I will be so grateful  : - )

Thank you,

Lewis.
chrome.jpg
InternetExplorer.jpg
Avatar of Dan McFadden
Dan McFadden
Flag of United States of America image

Here is a walk-thru on how to set up IIS to server a proxy.pac file.

Link:  https://marckean.com/2010/02/09/setting-up-proxy-pac-files-in-iis7-for-proxy-use/

The major item is to set up a dedicated site to server up the file.  As the article mentions, I also recommend setting up a dedicated FDQN for the site... I'm a fan of http or https://proxy.mydoamin.com

Dan
Avatar of Lewis Robertson
Lewis Robertson

ASKER

Hi, thanks for responding.
Already seen that link on my travels and checked everything.

I'm certain my issue is something to do with HTTP Response Headers.

If I remove Content-Type text/plain, Chrome then offers file download rather than showing inline, same as IE.
Put Content-Type text/plain back in and Chrome shows file contents in browser as per screenshot.

It's as if Internet Explorer is completely ignoring the HTTP Response Headers.
Whereas Chrome sees the change and responds to it.
How are you setting up IE?  Are you manually setting up the proxy settings or using auto-detect?

Link:  https://blogs.msdn.microsoft.com/ieinternals/2013/10/11/understanding-web-proxy-configuration/

Auto-detect has different requirements for DNS, DHCP and the file.

Dan
Manually.  But at this stage I'm not actually attempting to filter my traffic.


I'm literally just trying to get IIS to display this pac file's content as a webpage in internet explorer, rather than it being offered as a download.


I've just been testing further here trying to get Internet Explorer to display other proxy file formats...
.jvs, .js, .dat, all have the same issue in Internet Explorer.  But all work in Chrome.
Have you tried setting the HTTP Response Header to the content type of application/x-ns-proxy-autoconfig?

Dan
Yep tried that and just tried again, same issue.

Thing is that I know IE can definitely display a .dat file as our old proxy server publishes it's own using HTTPAPI and that works in IE fine.  So it's not even a case of IE not supporting the file types, I have proof that it can.  It's driving me a bit insane trying to crack this lol.
Setting the .pac MIME type to plain/text will server it up across all browsers.

Dan
Just tried that and getting the same issue.

By the way I'm testing this across 3 different laptops, one with IE8, one with IE10, one with IE11.
Before my last post, I setup a .pac file on a site and was able to display the proxy.pac file in IE11 when the content-type was set to plain text.

Purge your IE cache.

Dan
Already tried clearing all history on all 3 laptops, still same issue.
Try setting it up under another URL path.

Setting the .pac MIME type to text/plain does server it up as a text file in IE11.  I've verified it on 4 different IIS Servers.
Server 2008 R2, Server 2012, Server 2012 R2 & Server 2016. (IIS7.5, 8, 8.5 & 10)  IIS7 and IIS7.5 can be considered the same.

Dan
If you have an HTTP Response Header for content-type for text/plain... you should remove it after setting the .pac MIME type to text/plain.

I was able to reproduce the issue.  MIME type was text/plain & site was pushing a content-type of text/plain.  Removing the response header resolved the display issue.

Dan
Sorry, same issue after trying both suggestions  : - (  

Can you see why it is driving me insane lol.
From a "Run as Admin" console, type the following and please post back:

- C:\Windows\System32\inetsrv>appcmd list apppools
- C:\Windows\System32\inetsrv>appcmd list sites

Are you trying to use the "Default Web Site?"

Dan
APPPOOL "DefaultAppPool" (MgdVersion:v4.0,MgdMode:Integrated,state:Started)
APPPOOL "Intranet" (MgdVersion:v4.0,MgdMode:Integrated,state:Started)
APPPOOL "ASP.NET v4.0" (MgdVersion:v4.0,MgdMode:Integrated,state:Started)
APPPOOL "ASP.NET v4.0 Classic" (MgdVersion:v4.0,MgdMode:Classic,state:Started)
APPPOOL "IntranetV3" (MgdVersion:v4.0,MgdMode:Integrated,state:Started)
APPPOOL "Intranet Dev" (MgdVersion:v2.0,MgdMode:Integrated,state:Started)
APPPOOL "Classic .NET AppPool" (MgdVersion:v2.0,MgdMode:Classic,state:Started)
APPPOOL "WebFilter" (MgdVersion:,MgdMode:Integrated,state:Started)


SITE "Default Web Site" (id:1,bindings:http/*:80:,net.tcp/808:*,net.pipe/*,net.msmq/localhost,msmq.formatname/localhost,state:Started)
SITE "Intranet" (id:2,bindings:http/10.1.0.6:80:intranet.co.uk,http/10.1.0.6:80:intranet,state:Started)
SITE "Intranet Dev" (id:3,bindings:http/*:80:dev-intranet,http/*:80:dev-intranet.mts.local,state:Started)
SITE "WebFilter" (id:4,bindings:http/10.1.0.6:80:mts-webfilter,state:Started)
Which site is hosting the .pac file?

Dan
Apologies, it is the one called WebFilter.
On the WebFilter site, can you add the following HTTP Response Header:

NAME:  Content-Disposition
VALUE:  inline

I came across a note while reading deep thru this article from MSDN:  https://msdn.microsoft.com/en-us/library/gg622940(v=vs.85).aspx

Dan
Done. Still same issue.
Thanks for taking the time to help wit this by the way  : - )


        <httpProtocol>
            <customHeaders>
                <add name="Content-Disposition" value="inline" />
            </customHeaders>
        </httpProtocol>
Have you tried IE in compatibility mode?

I'm leaning toward an IE issue, not necessarily an IIS setup issue.

Dan
Hi again, yep tried that.

3 different laptops too.

Same issue.
Are your computers sitting behind a proxy that doesn't bypass local addresses?
 
It's a stretch of a question, but I am running out of ideas.  This appears to be a cache issue, especially after changing the Response Header content type to plain text.  I was able to reproduce your scenario on my system and then resolve it.

Dan
They are not sitting behind any proxy.

I've given up on this now, but thanks for your responses Dan, much appreciated.
Sorry we weren't able to find a solution to your situation.

Dan
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.