0

I'm using IIS to reverse proxy HTTP requests to a nodejs app running in the same machine.

URL rewrite and ARR modules are installed and the proxy setting checked. The URL matching seems good: if I change the rule to redirect it works as expected. Using rewrite I get a 404 error.

The API endpoint is api.url.com/getContent/ofertas. The IIS site root folder is W:\sites\LocalUser\site\api. Here is the web.config file.

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="UrlRewriteLocalhost" enabled="true" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="http://localhost:8801/{R:1}" />
                </rule>
            </rules>
        </rewrite>
        <defaultDocument>
            <files>
                <remove value="index.htm" />
                <remove value="index.html" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

I'm sure that in the past I had similiar setup in another machine with a similar web.config file. I've worked out problems in the past (mainly about FTP) using procmon and here are my findings:

Procmon screen shots

These are the procmon logs when I access the URL with the rewrite vs redirect rule. Notice that on the redirect rule the web.config file is resolved in the correct path (red arrow). With the rewrite rule it seems that it can't be resolved to the correct path.

404 error with the rewrite rule

Adding to that, if I interpert the error description correctly it looks that it's not finding an appropriate file handler, because there is none set up. Also by looking at the 'PhysicalPath' it looks like it's requesting the wrong path, which makes sense backed up by the procmon logs.

I read somewhere that the URL rewriting comes before the handler mappings situation so does this mean that URL rewriting is not working properly? Where do I go next from here?

1 Answer 1

0

Well I swear I was having this issue for more than a week. After posting the question I went through everything again, checked every IIS feature possible.

Something that set me off was knowing that URL redirect was working, with the redirect rule, but the rewrite, that needs the ARR to work, was not.

While inspecting the 'Modules' feature I noticed that there was an entry for the URL rewrite module named RewriteModule but none sugesting ARR. I went to the 'Actions' -> 'Configure Native Modules...' and there it was the ApplicationRequestRouting module waiting for being ticked...

I also followed this Microsoft article and executed the step number 3. I don't think it's part of the solution, but I tought it's worth mentioning.

I hope this helps someone!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .