ReverseProxy for IIS 6.0 in CS using ASP.NET: Difference between revisions

From
Jump to navigation Jump to search
Line 35: Line 35:
=== Walk through ===
=== Walk through ===
# Create Direktory where software lives e.g. <code>C:\Inetpub\test_virtual</code> and extract archive <code>"\\dc\pub\2006\2006 Software\ReverseProxy_15_SAR.zip"</code> to that directory. [[Image:rproxy_1.png]]
# Create Direktory where software lives e.g. <code>C:\Inetpub\test_virtual</code> and extract archive <code>"\\dc\pub\2006\2006 Software\ReverseProxy_15_SAR.zip"</code> to that directory. [[Image:rproxy_1.png]]
# Create in the IIS MMC a virtual directory
# Create in the IIS MMC a virtual directory[[Image:rproxy_2.png]]
## [[Image:rproxy_2.png]]

Revision as of 12:08, 11 May 2006

Problem to solve

We want to embed content from a internal webserver e.g. http://foo to our public webserver http://sar.informatik.hu-berbin.de. In particular the frontend request http://sar.informatik.hu-berbin.de/test/bla.html should get the response for http://foo/dir/bla.html. Thus the mapping is:

  • http://sar.informatik.hu-berbin.de/test -> http://foo/dir.

From outside this sould be look like a local web directory.

Used Software

IIS Reverse Proxy in particular v1.5. In that release of software redirections of the backend server are not forwarded transparently to the frontend. Therfore we patched the C-Sharpe code to take care of that. We disabled the internal handling of redirections and transpose them instead to the frontend.

38c38
<   	const int MaximumRedirections = 50;
---
> 		const int MaximumRedirections = 0;
357a358,370
> 			switch((int) backEndResponse.StatusCode) {
> 				case 301:
> 				case 302:
> 				case 303:
> 				case 307:
> 					frontEndResponse.StatusCode = (int) backEndResponse.StatusCode;
> 					string newLocation = backEndResponse.Headers["Location"];
> 					newLocation = Regex.Replace(newLocation, backEndSite, 
> 						frontEndRequest.Url.GetLeftPart(UriPartial.Authority) + frontEndRequest.ApplicationPath, 
> 						RegexOptions.IgnoreCase);
> 					frontEndResponse.RedirectLocation = newLocation;
> 					break;
> 			}

Then redirections which usally occur if you enter e.g. http://foo/dir -> http://foo/dir/ are forwarded to the browser as http://sar.informatik.hu-berbin.de/test -> http://sar.informatik.hu-berbin.de/test/

Installation

Based on W2k/XP, Win2003

Walk through

  1. Create Direktory where software lives e.g. C:\Inetpub\test_virtual and extract archive "\\dc\pub\2006\2006 Software\ReverseProxy_15_SAR.zip" to that directory. Rproxy 1.png
  2. Create in the IIS MMC a virtual directoryRproxy 2.png