Redirecting HTTPS call to a .NET Core Web API with IIS and Kestrel

2.4k views Asked by At

hopefully someone can help me.

This is the scenario I want to implement:

Server A has IIS installed and hosts a web app "mysite.com" and some web apis. Server B has a .NET Core Web API hosted as a Windows Service.

When a client makes a request to a specific port like "mysite.com:9091/api/get-value" I would like for IIS to re-route that call with same payload to server B on "myapi:9091/api/get-value" through HTTP.

The reason I want to do this is because We have authentication and certificates already configured on Server A, and also we want all incoming requests to go through the main site.

I have been reading on reverse proxy with IIS, and it would seem to be what I need, but it's not clear if the hosted app that will be running under Kestrel must be on the same physical machine as the IIS Web Server (i.e. Server A), or I can re-route to whichever other server I want, as long as it's on same network.

Any thoughts will be appreciated.

Hopefully my question is clear enough, otherwise please do let me know and I'll try to rephrase.

1

There are 1 answers

0
Jalpa Panchal On BEST ANSWER

It is not necesarray to have both kestrel and iis on same server.

You could use the iis URL rewrite rule and reverse proxy to forward the request to the Kestrel server:

https://techcommunity.microsoft.com/t5/iis-support-blog/setup-iis-with-url-rewrite-as-a-reverse-proxy-for-real-world/ba-p/846222

Host ASP.NET Core on Windows with IIS

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-3.1