 |
|
 |
Works fine until the size of the page to be rendered is too big (e.g. many records returned). The page will render partialy and then hang for a while (130 seconds; IE8 progress bar at 30%) and then finish rendering the page but the page is incomplete.
|
|
|
|
 |
|
 |
Thanks for the code.
I've stripped out a lot of the code I don't need for my implementation but there is a problem with the output of the receiveStream output. The resources I am proxying are XML documents. The proxy returns them identically to the source server, but somehow appends a null character (0x00) to the end of the stream. I've run it through the debugger and it is not present in receiveStream so it is either by the context.Response.OutputStream.Write(buff, 0, bytes); line or the context.Response.End(); line.
I wouldn't worry about it if it didn't cause browsers to consider the XML doc malformed!
Does anyone know what introduces the stray character?
Thanks!
Steven
|
|
|
|
 |
|
 |
Hello,
i would like make reverse proxy with WCF-Service.
Can everybody help me?
Thanks.
Walter
|
|
|
|
 |
|
 |
I'm using this proxy by the following:
google.mydomain.com will get the google.com website
yahoo.mydomain.com will get the yahoo.com website
and so on like that.
if i want to go to mydomain.com/login/default.aspx or some other page, how can I bypass the request and go directly to this page ignoring all of the reverseproxy code?
thanks
|
|
|
|
 |
|
 |
I cannot figure out how to set up the demo project at my side. There are no installation instructions, only the global and web.config and a dll. How to start with it now?
|
|
|
|
 |
|
 |
Following are its deployment instructions;
1. Create a new directory named Handler under the C:\Inetpub\Wwwroot directory.
2. Copy the bin directory with the dll (ReverseProxy dll) and the web.config in the Handler directory.
3. Follow these steps to mark the new Handler directory as a Web application:
4. Open Internet Services Manager.
o Right-click the Handler directory, and then click Properties.
o On the Directory tab, click Create.
o Follow these steps to create an application mapping for the handler. For this handler, create a mapping to the Aspnet_isapi.dll file for the .* extension.
o Right-click on the Handler Web application, and then click Properties.
o On the Directory tab, click Configuration.
o Click Add to add a new mapping.
o In the Executable text box, type the following path: Microsoft Windows 2000:
C:\WINNT\Microsoft.NET\Framework\<version#>\Aspnet_isapi.dll
o Microsoft Windows XP:
C:\WINDOWS\Microsoft.NET\Framework\<version#>\Aspnet_isapi.dll
o In the Extension text box, type .*
o Make sure that the Check that file exists check box is cleared
o Double click the path textbox if OK button is not enabled; and then click OK to close the Add/Edit Application Extension Mapping dialog box.
o Click OK to close the Application Configuration and the Handler Properties dialog boxes.
o Close Internet Services Manager.
Now browse to http://localhost/Handler/http//www.google.com – for mode 0
And http://localhost/Handler/ - for mode 1
|
|
|
|
 |
|
 |
You can also copy the ReverseProxy.cs into a folder called App_Code within your web application. In your web.config file, when you add the httpHandler, set the type to "ReverseProxy.ReverseProxy" (leave out the text past the comma).
|
|
|
|
 |
|
 |
I used this code to set up another IIS 6 website in parallel with my public site. This is a secure (SSL) site. So I wanted to use https externally to access internal http servers (Nagios running on Apache on Linux). Here is a summary of the changes that I made. First, note that I did not test the "all sites" proxy mode, just the individual site mode.
So my IIS 6 setup looks like this:
Default site (my primary HTTPS site)
nagios1 (my first nagios server)
nagios2 (my second nagios server)
nagios1 and nagios2 each have the ReverseProxy application installed in the root. On IIS 5 & 6, if you want to map all mime types to the ihttphandler, you must do it for the entire site. That is why I didn't just use a virtual directory. IIS 7 removes this restraint.
The first change was to this section:
string remoteUrl;
if (proxyMode==0)
remoteUrl= ParseURL(context.Request.Url.AbsoluteUri); else
remoteUrl= context.Request.Url.AbsoluteUri.Replace("http://"+
context.Request.Url.Host+context.Request.ApplicationPath,remoteWebSite);
There were 2 issues. The first was that "http://" was hard coded. Wouldn't work for https. In my case, the external site was https and internally it was http. After the following changes, this wasn't an issue. The second issue was that sometimes "proxy.aspx" was in the URL, sometimes not. I put some code in to check for this as well:
string remoteUrl;
string sProtocol = context.Request.Url.Scheme + "://" +
context.Request.Url.Host + context.Request.ApplicationPath;
remoteUrl = context.Request.Url.AbsoluteUri.Replace(sProtocol, remoteWebSite); int iLength = remoteUrl.LastIndexOf("proxy.aspx");
if (iLength > 0)
remoteUrl = remoteUrl.Substring(0, iLength);
A second issue was that on any error, "404" was returned, which made it very hard to determine what the real back end error was. I changed the exception block to pass along the backend error with a description:
Original code:
catch(System.Net.WebException we)
{
context.Response.StatusCode = 404;
context.Response.StatusDescription = "Not Found";
context.Response.Write("<h2>Page not found</h2>");
context.Response.End();
return;
}
New code:
catch(System.Net.WebException we)
{
int iStatus;
string sStatus;
sStatus = we.ToString();
int iIndex = we.ToString().IndexOf('(');
iStatus = 491; if (iIndex != -1)
iStatus = Convert.ToInt32(we.ToString().Substring(++iIndex, 3));
context.Response.StatusCode = iStatus;
context.Response.StatusDescription = we.Message;
context.Response.Write("<h2>From ReverseProxy - " + we.Message +
"</h2><br><center><h3><br>" + we.Data + "<br>URL: " +
we.Response.ResponseUri + "</br></br></h3></center>");
context.Response.End();
return;
}</br>
Lastly, the remapping of the links didn't work if the application was in the web site's root directory. This was because the replacement string was basically a single '/'. In this case, the browser would not have the correct relative path or the absolute path.
The solution was easy. Pass the absolute path. So
content= ParseHtmlResponse(readStream.ReadToEnd(),context.Request.ApplicationPath);
becomes
content = ParseHtmlResponse(readStream.ReadToEnd(), sProtocol);
Note that "sProtocol" was calculated above.
And finally, change ParseHtmlResponse from
public string ParseHtmlResponse(string html,string appPath)
{
html=html.Replace("\"/","\""+appPath+"/");
html=html.Replace("'/","'"+appPath+"/");
html=html.Replace("=/","="+appPath+"/");
return html;
}
to
public string ParseHtmlResponse(string html,string appPath)
{
html = html.Replace("\"/", "\"" + appPath);
html = html.Replace("'/", "'" + appPath);
html = html.Replace("=/", "=" + appPath);
return html;
}
Since the trailing backslash is already included in sProtocol.
These changes did not break the way the code worked originally, but they do make it more robust and work in more environments.
Finally, to save others a lot of heartache, here is a link to an article on how to create a server certificate that can be shared by different sites on the same machine using SSL host headers. This is non-obvious, and you can't have multiple SSL sites without it.
http://thelazyadmin.com/blogs/thelazyadmin/archive/2006/06/16/IIS-6.0-and-SSL-Host-Headers.aspx[^]
Also, remember that the "common name" for each site must be in DNS so IIS knows which site to direct the request to.
Now you can host multiple servers from a single IIS servers, using https externally and http internally ig you desire.
Hope this helps others.
Rick Bross
Hope this helps others.
|
|
|
|
 |
|
 |
In regards to remapping fo URLS in ParseHTML routine, why would you change all paths to absolutepaths?
Aren't you supposed to leave everything relative to the address on the browser (ie context URL)?
If you point the links to an absolute value, you risk changing the address on the address bar.
Isn't reverse proxy supposed to act as if it supplying the content from the address that the user types in, ie on the browser??
Those who try and those who fry!
|
|
|
|
 |
|
 |
Salut Vincent
Je t'explique ma problematique:
J'ai un site Web classique les internautes clique sur un lien qui redirige vers une serveur Web situe dans un dmz (la ou j'ai installe ta solution) nesuite le resverse proxy redirige vers des pages html situe sur un serveur dans le lan. Je voudrait implemente une securite au niveau du firewall
mais quand je passe par ta solution si je regarde la variable remote address elle me sort toujours celle de l'internaute et non celle de ton proxy comment faire pour avoir la remote adress correspondant à la machine hebergeant dans la dmz ton proxy
merci à toi
marc.casadaban@gpi-info.net
|
|
|
|
 |
|
 |
Where is the install documentation? The only files in the ZIP are the Web.config, Global.asax, and the DLL. No readme.txt, install.txt, or anything.
|
|
|
|
 |
|
 |
My Application requires that the reverse proxy server does not change the host header. It must be forwarded fully transparently from the browser to the server. This is necessary to be able to differentiate between Internet requests and intranet requests.
For example, Apache reverse proxy (mod_proxy) has the configuration option 'ProxyPreserveHost' to support this feature.
This reverse proxy support this above feature. Pls reply as early. Thanks in advance.
Paul
|
|
|
|
 |
|
 |
I think Paul, you will need to capture each header in the request object and pass them on. This is in order to keep the actual request the same as it was sent from the client.
No one is born a .net developer, you become one!
|
|
|
|
 |
|
 |
That doesnt seem work for ASP.NET pages. The httpWebResponse object does not appear to allow the programmer add asp.net response headers. I have tried and it simply errors.
Regaurds,
Stimphy
|
|
|
|
 |
|
 |
I got the output, But once i try to navigate from that page I get an error for example: If i call google.com from proxy. I get an error while searching a page from the proxy. What shall I do for that.
|
|
|
|
 |
|
 |
Hi,
Interesting code, simple and to the point, thanks for posting it. I've had a need for a slightly more featureful reverse proxy script, mostly that passes headers correctly in both directions. I've coded this up, taking inspiration from your script and another one that used to be online but has disappeared. It's at http://code.google.com/p/iisproxy/[^] if you want to take a look. Hope this is ok by you,
Paul
|
|
|
|
 |
|
 |
I got the following errors in Event Viewer
Event Type: Error
Event Source: W3SVC-WP
Event Category: None
Event ID: 2214
Date: 4/13/2008
Time: 2:18:20 PM
User: N/A
Computer: SERVER
Description:
The HTTP Filter DLL C:\Inetpub\wwwroot\test\bin\ReverseProxy.dll failed to load. The data is the error.
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 7f 00 00 00 ...
Event Type: Error
Event Source: W3SVC-WP
Event Category: None
Event ID: 2268
Date: 4/13/2008
Time: 2:18:20 PM
User: N/A
Computer: SERVER
Description:
Could not load all ISAPI filters for site/service. Therefore startup aborted.
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 7f 00 00 00 ...
|
|
|
|
 |
|
 |
I need to use your application to open a website on port 8080
|
|
|
|
 |
|
 |
Hi,
I try it on IIS 7.0 but I don't know how configure the server. I have made the mapping ISAPI but I have the Error HTTP 403.14 - Forbidden.
Have you got any solution ?
chears.
|
|
|
|
 |
|
 |
what if Application sends;P file from server side??
can we enable file passing to the client browser via this proxy...(indirect file LINKING) such as .rar .zip .pdf .exe..
I tried with some of the doc file but as there is stream reader it shows doc file content with some of the garbage value in the browser..
Hope to have your reply soon..
Thanks in advance...
TARAK
|
|
|
|
 |
|
 |
Very usefull for me. View my project for download files from rapidshare.com based on this sample http://www.xd24.ru/start.aspx
Absolutly free download files from rapidshare.com and rapidshare.de via asp.net proxy! No wait! Thanks.
|
|
|
|
 |
|
 |
Sorry Vincent, but I couldnt get the reverse proxy work. I tried install the demo in my IIS but it didnt work.
I have IIS 6 and I couldnt configure IIS, that file extension you mentioned.
What about the reverseproxy.dll? Should I configure it anywhere to get it run?
Should I create an virtual directory to this app?
Please help
best regards from Brazil
Jean
|
|
|
|
 |
|
 |
hi i am not sur eif this article watched but proxy does not give correct path for images.
for example if you browse google
http://localhost/http/google.com
images links becomes
//http//google.com/images/nav_logo2.png
all internal links becomes
//http//google.com/....
any ideas how to fix it?
|
|
|
|
 |
|
 |
guys!
any ideas how to fix it?
|
|
|
|
 |
|
 |
Salut Vincent,
Je vais essayer ton reverse proxy sur une machine Windows 2000 server a partir de lundi, mais j'ai une question prealable: Est-ce que ton proxy forwarde des cookies? Ou faudrait-il plus pour cela?
Merci en avance,
Felix
|
|
|
|
 |