Fog Creek Software
Discussion Board




how to proxy a web app?

Hi folks,

I'm trying to write a simple web app (in ASP.NET, but that's not really important) that simply acts as a reverse proxy server to a commercial (classic ASP) Web app we have. The idea is that an Internet user connects to http://proxyserver/foo.aspx. The proxy fetches http://someinternalserver/foo.aspx, and sends it back to the user to satisfy his request.

This would be a relatively straightforward thing to do if I were just dealing with static HTML pages, but I'm not -- I'm dealing with a closed-source application whose inner workings are a mystery to me, and I need to figure out how exactly the app is communicating with the browser to maintain state and so on -- cookies, POST form fields, querystring, etc., so that I can properly proxy it.

I've been kind of stumbling around trying to find a way to figure this out, but I've had limited success -- the app "sort of" works, but many features are broken. Any pointers?

Oh, and by the way -- the reason I'm not using an out-of-the-box proxy server is because I need to actually do stuff with the proxied pages before sending them back to the user, such as filtering out/replacing text.

Thanks!

gld
Thursday, August 12, 2004

Why?

motivation-al speaker
Thursday, August 12, 2004

I would recommend ethereal.

Li-fan Chen
Thursday, August 12, 2004

Try using Mozilla with the live HTTP headers plugin. This gives you a nice dump of all the headers sent between the client and server, cookies, cgi-params, etc...

GB
Thursday, August 12, 2004

this task is not for you if you asking questions like this.

dontbestupid
Friday, August 13, 2004

Write a System.Web.IHttpHandler (http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebihttphandlerclasstopic.asp)
or maybe even a System.Web.IHttpAsyncHandler that uses a System.Net.HttpWebRequest (http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemnethttpwebrequestclasstopic.asp) to fetch the page and do your filtering and  return it as the Response.

If you ask nicely I might do it for you (probably between 2am - 4am ;->)

Gary van der Merwe
Friday, August 13, 2004

Okay, probably a dumb question, but...

Do you really need to know anything about what is contained in the http requests? 

It seems to me that you should just be able to pass the request and response through without needing to know what is actually in it.

Steve Barbour
Friday, August 13, 2004

*  Recent Topics

*  Fog Creek Home