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.

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. With the rewrite rule it seems that it can't be resolved.

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?

2
  • well, the fundamental difference between an redirect and a rewrite, is that a redirect sends the client back a 301/302 response with the new url, and lets the client browse to it. redirection however is purely server-side, and the client doesn't even know it happened. are the rewritten/redirected URLs equally accessible from both a remote client, and a client running on the server itself? Jun 22, 2023 at 3:18
  • @FrankThomas No, the nodejs app is running on localhost, on the server. I wanted to route the API requests from IIS binding api.url.com to localhost:3000. Accessing the API url from a remote client with the redirect rule shows up localhost:3000/getContent/ofertas in the browsers url bar which does not work, but it's the expected behaviour. Jun 22, 2023 at 12:42

1 Answer 1

1

I really need this to work out so I went through everything again and 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 .