 |
|
 |
I have followed the steps and I receive this error could not load type 'ReverseProxy,.ReverseProxy' from assembly. Relatively new to attempting this but could use assistance.
|
|
|
|
 |
|
 |
Hello,
This article provides a very good insight. I did follow the instructions to set up the reverse proxy,but, unable to get it working. My issue is with identifying the correct url.
For example, the Reverse Proxy (handler) resides on server1:8080 and the remote server on which my application resides is server2:8080. What should be the final url?
http://server1:8080/handler/server2:8080/WebApp/Default.aspx
Is this correct assuming that WebApp/Default.aspx is the link to my application. Any suggestions in this context will help.
Thanks
|
|
|
|
 |
|
 |
Code is clean, follows good coding standards, and the design looks good. An improvement over similar examples of reverse HTTP proxies.
|
|
|
|
 |
|
 |
If you love this software proxy (which is great for mocking what happens in hardware) then you've probably seen that whenever an web exception like 500 happens, all you get is the hard coded 404 message defined in the try...catch... in this article.
public HttpWebResponse GetResponse(HttpWebRequest request)
{
HttpWebResponse response = null;
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (System.Net.WebException e)
{
_context.Response.StatusCode = (int)((HttpWebResponse)e.Response).StatusCode;
_context.Response.StatusDescription = e.Status.ToString();
Stream tResponseStream = e.Response.GetResponseStream();
StreamReader tResponseStreamReader = new StreamReader(tResponseStream);
_context.Response.Write(tResponseStreamReader.ReadToEnd());
_context.Response.End();
return response;
}
return response;
}
Change the response code to this and the errors from the proxy target will come back to your browser.
What is a Jim?
|
|
|
|
 |
|
 |
public HttpWebResponse GetResponse(HttpWebRequest request)
{
HttpWebResponse response;
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (System.Net.WebException ex)
{
response = ex.Response as HttpWebResponse;
}
return response;
}
|
|
|
|
 |
|
 |
I need to server this on a different port, say 88. It does not work from a different port, any ideas?
|
|
|
|
 |
|
 |
You must configure IIS with this port : "WebSite Properties / Advanced".
|
|
|
|
 |
|
 |
Done that.
For example I have setup http://66.39.178.157/Dell to proxy the Dell website. I have also added a certificate to it and https://66.39.178.157/Dell does not work. When trying https I don't see any attempt to retrieve Dell's website to proxy it. Side note the certificate does not match the site. If I change IIS to 88 for http then http://66.39.178.157:88/Dell still will not work. Also setup an additional virtual directory "Photos" which is just http on another box with browsing.
I have also setup another site called “test” with it’s own file structure and virtual directories “Dell” and “Photos”. It is on port 99 for http and 444 for https. So http://66.39.178.157:99 and https://66.39.178.157:444 will show the default iisstart.htm page. But http://66.39.178.157:99/Dell will not work.
Thanks for looking at this.
Screenshots are available at http://66.39.178.157/Screenshots
I have taken 66.39.178.157 offline.
modified on Sunday, June 14, 2009 12:16 AM
|
|
|
|
 |
|
 |
does it work for https too?
thank you
|
|
|
|
 |
|
 |
I've don't try this, but yes... All encryption / decryption processes are executed by IIS (and not by this code)... So, try it, and let's a message here
|
|
|
|
 |
|
 |
Any ideas as to why I'm getting a 404 error on any file other than aspx, asmx..
I modified the code so a subdirectory "proxy/" forwards all requests onto another instance of IIS
I can call aspx, asmx pages all day long and it works properly, however if I request "proxy/image.gif" I get a 404 (and it looks like a 404 from IIS hosting the proxy, and not the Response.Write("Page not found"); as listed in your code)
Any help would be immensely appreciated.
Thanks,
Tim
*Edit* PS. Inside the Visual Studio 2008 debugger, all requests get passed properly (I have two web projects in the same solution, operating on different ports to simulate two different servers). This points me to the direction of IIS not passing the request properly, or not handling the response. Like most apps, it works great in the debugger, then craps out in production. (The wildcard was configured per your instruction)
|
|
|
|
 |
|
 |
Are you sure to have in your web.config and to exactly use the deploiement method (in article)? With these items, you set IIS to capture all requests (include gif, ...) to the new DLL.
|
|
|
|
 |
|
 |
Well, I think I'm closer. The only step I cannot recreate is the "verify if file exists" step in IIS. I'm in IIS 7 (arg).
IIS 7 must be checking to see if the *.gif (etc) files exist before even looking at the handler.
If you can offer any feedback on how to get this to work in 7, let me know.
I will absolutely post my solution if/when it works.
*Edit* The httphandler section has a property for "validate=false" but still no luck
What is a Jim?
modified on Tuesday, February 3, 2009 9:37 PM
|
|
|
|
 |
|
 |
Bingo... My web.config looks like this now... Please note, I had to unlock IIS 7 to override the handler according to: http://forums.asp.net/t/1240344.aspx
<system.web> <httphandlers> <add validate="false" verb="*" path="*" type="ReverseProxy.ReverseProxy, ReverseProxy" /> </httphandlers> <customerrors mode="Off" /> </system.web> <system.webserver> <handlers accesspolicy="Read, Execute, Script"> <add name="Wildcard" path="*" verb="*" modules="IsapiModule" scriptprocessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourcetype="Unspecified" requireaccess="None" precondition="classicMode,runtimeVersionv2.0,bitness32" /> </handlers> </system.webserver>
I hope this helps What is a Jim?
|
|
|
|
 |
|
 |
For some reason, all I'm getting from this is 404 errors. I have IIS 6 on server 2003 on one IP address and Apache on the same server with a different IP. I am trying to proxy over to apache.
When I look in the IIS logs, they have a 404 for each time I tried.
Any ideas?
Does it make a difference that the requests are coming in to apache on a non-standard port but getting forwarded to 80?
|
|
|
|
 |
|
 |
read my response titled:
"Add/Edit this code to make error messages much more descriptive"
Hope that helps.
What is a Jim?
|
|
|
|
 |
|
 |
Hello Denis, great code by the way. That's exactly what I needed.
I used your code and changed a few things since I need to modify the message's body before relaying it to the Remote Host and it works great on my workstation.
I'm on XP Pro with IIS 5.
When I deployed the ReverseProxy on it's dedicated server, which is running Windows Server 2003 and IIS 6 it's a different story. The server accepts the request, sends it to the remote host, gets the answer back but I never get the final answer in the calling app.
I get a "Connection with the server has been reset" messasge. This message is generated by the Power Tcp librairy we use to communicate. I even tried installing the calling app on the server itself and I get the same result.
I timed every calls and it seems that as soon as the proxy turns around to relay the post to the remote host the connexion is droppep between the server and my calling app.
It's been 2 days now that I'm trying to figure out the source of this and I'm not making any progress what so ever.
I'm now turning to you... Do you have a hint about what could be causing this?
Thank you very much.
Rombolt
|
|
|
|
 |
|
 |
Hello,
Thanks... but I've also installed this code on Windows Server 2003 with IIS6 and everything works perfectly.
Do you have a firewall between your reverse proxy and your remote server?
Denis
|
|
|
|
 |
|
 |
Hello again Denis, I have found the cause of the issue and resolved it.
It seems that there is a security feature (patch) that was released for IIS6 on Windows Server 2003 that does not affect IIS5 on XP.
In my client app. I am injecting user-defined headers that do not exist on the proxy page I am calling and this security patch is made so to drop the communication when such a scenario occurs. Unfortunately this is not the case on my IIS5 so it took me a while to figure it out.
These extra headers are required by the remote server we are trying to reach. So instead, I put the extra information in the body, parse it on the proxy and build a new message with the extra info in the headers before forwarding the new message to the remote server and all is good.
Thanks for your time and for the Reverse Proxy sample code.
Rombolt
|
|
|
|
 |
|
 |
Hi,
nice article and nice code!
What if the pages on the remote (internal) server are protected with basic HTTP authentication? Is there a way to re-route the 401 code page to the the client? It would be nice if I could avoid storing the user name and password for the authentication and just hand back to the remote server what I got from the client.
This means not hard coding user name and password in the NetworkCredential object, neither having to collect those in a login page, saving them on a session or cookie and rerouting through a NetworkCredential object.
Thank you,
Giorgio
|
|
|
|
 |
|
 |
You can add your own credentials system (logged in user). Add your code at the end of GetRequest method:
public HttpWebRequest GetRequest()
{
...
request.Credentials = CredentialCache.DefaultCredentials;
return request;
}
But if you use the Login Control (asp:login), the actual code is correct because the authentication is sent by POST and associated token is stored in a cookie. For example, currently, I'm using this code to forward all requests to a domain (www.mydomain.com) to an Apache Server in my internal network... and on this Apache Server, I'm hosting a CMS created with MySQL/PHP
modified on Tuesday, December 9, 2008 7:42 AM
|
|
|
|
 |
|
 |
How should I configure IIS 7.0to do the same?
Thanks /// Angelo
|
|
|
|
 |
|
|
 |