0

I'm trying to setup a reverse proxy using IIS to proxy request on port 80 to a local virtual machine on port 8080. The rewriting rule was setup using IIS GUI "Reverse Proxy" rule. However it work very strangely:

If there is a file/folder in the web folder (physical path), then the reverse proxy work. Otherwise, it throw 404 error.

For example, for a request to "http://example.com/myfile", if there is a file name "myapp" in the web folder then it get rewritten into "http://example.com:8080/myfile" properly. On the other hand, if there is no file "myfile" locally, then I get 404 error. It is as if there is something that check existence of a local file (and throw 404) before URL rewrite rules are processed.

I try disable some handles, re-order modules, and none seems to work :(

Running IIS 7.5 on Windows Server 2008 R2

0

Ok, I finally get it working by removing IsapiFilterModule and IsapiModule from the site.

0

It worked for me by taking off the runAllManagedModulesForAllRequests="true" from modules element in configuration. I think this is causing to run all the site level modules first than reaching the UrlRewrite module.

0

I only needed a reverse proxy for one application server running locally. I was getting a 404 but then added <httpRedirect enabled="false" /> to my web.config in the site's physical directory and it worked. My web.config looks like this

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpRedirect enabled="false" />
        <rewrite>
            <rules>
                <rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="http://localhost:8153/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
0

If you have ASP.NET MVC application and get 404 error, this can be resolved by adding ignore path to routes.

routes.Ignore("path to ignore");

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.Ignore("api/controllerNmae/actionName");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.