Can I use this for a local proxy which tracks internet usage per application?

Apr 12, 2010 at 7:26 AM

Hi,

Q1 - Could I use URL Rewriter and Reverse Proxy to act as local proxy on my PC? (or a portion of it, assuming I can jump into the code)

That is, I would configure each application on my PC that uses internet (e.g. browsers) to have a proxy setting of say "localhost:8080".  Then have URL Rewriter and Reverse Proxy running on the PC at localhost:8080 and effectively proxy the request/response.

Q2 - If yes, then the next question, what if after the request is proxied by URL Rewriter and Reverse Proxy whether it could then go to the normal company proxy server?  i.e. does URL Rewriter and Reverse Proxy have a way to configure a proxy server for it's HTTP requests it makes itself?  So overall then the chain would be:

     PC App (local) => URL Rewriter and Reverse Proxy (local) => Normal Proxy (WAN) => target web page (Internet)

Q3 - If yes, would this also work for HTTPS as well as HTTP?

Q4 - And would it work for a "target web page" which has basic authentication setup (i.e. browser prompts for the site username/passwrod) - once everything else is working to this point, I assume this should then work by default?

 

thanks

Coordinator
Apr 13, 2010 at 1:13 PM

Q1 - yes you can

Q2 - yes see <system.net>/<proxy> to set the proxy .NET will use for requests

Q3 - yes HTTPS works too

Q4 - it also works for basic authentication

Apr 13, 2010 at 1:45 PM

thanks - I've been looking into it more, but I'm really stumped re the HTTPS aspect.  I've just looked into the "ProxyHandler.cs" source file.  Questions I have:

a) I can't see how with HttpListener to get it working for both HTTP and HTTPS listening at the same port?  I get an error.  I have posted this here. 

b) My assumption re my question a) above is that, as I'm creating a windows console application standalone (not running on IIS) that I'm need to use HttpListener to capture the HTTP(S) requests before passing them into the ProxyHandler.cs methods - is this correct?

c) I'm assuming as I would be configuring my local browser and applications to use a proxy server of "localhost:8080" that this would be correct for both HTTP and HTTPS - is this correct?  That is the SSL/HTTPS traffic from the browser would be going out to port 8080 too?

d) Assuming then the HttpListener can pick up the HTTPS request, I'm not sure whether there is any special requirement to setup a certificate and assign it somehow to the HttpListener?  That is could HttpListener + HttpWebRequest (within "ProxyHandler.cs") be enough to proxy HTTPS, or does there need to be some certificates setup.  I've googled and seen some posts re HttpListener & SSL where people talk about setting the certificates up. 

e) Are there any specific WebRequest http headers required to allow the proxying of HTTPS traffic from one local HttpWebResponse into a new external HttpWebRequest?  e.g. any flags/headers that specifically arrange that the https receiving code doesn't need to terminate the connection but just pass on, on the originators behalf?  

 

thanks heaps