blane
blane

Reputation: 369

IIS site application as proxy to another application on different server

I have two servers: S1 and S2, server S2 is not public, accesss to this server is possible only from S1. On my S1 server I want host web app (front-end) and on S2 I want to host API (backend) for this application. How I can configure new application on my IIS SITE which can send all request to another app hosted in IIS on S2?

Expectations

Is is possible to do this on IIS?

Upvotes: 1

Views: 2371

Answers (1)

YurongDai
YurongDai

Reputation: 2375

If I understand correctly, since your server S2 is not public, users cannot access S2 directly, only from S1. You want the client to send a request to s1.com/api, and then forward the request to s2.com/api. After the server S2 processes the request, it returns the response to s1.com/api, and then returns it to the client.

This requires S1 as a reverse proxy server, client → S1 (reverse proxy server) → S2 (target server)

Follow the steps below to set up a reverse proxy server S1:

The proxy URL for Web API suppose port is 8082 on server s1, and the real URL for Web API suppose port is 8085 on server s2. (Setting different ports is for easy distinction, of course, it can also be set as the default port.)

1.Download and install the URL rewrite module. (URL Rewrite must be installed before ARR because ARR depends on URL Rewrite.)

2.Download and install the Application Request Routing module.

After installation, you should be able to see the Application Request Routine Caching and URL Rewriting feature in IIS Manager.

image1

3.Open IIS Manager, double-click ARR, click "Server Proxy Settings" on the right, select Enable Proxy and apply. This makes ARR a server-level proxy.

image2

4.Select the website(here listening on port 8082) and double-click URL Rewrite to open the feature.

image3

5.Click Add Rule, select Reverse Proxy and click OK. In the Add Reverse Proxy Rule dialog, enter the URL of the Web API on the s2 server and click OK.

image4

6.At this point, a ReverseProxyInboundRule will be automatically generated, and you can modify the rules according to the actual situation.

image5

7.Eventually you can access s2 .com/api by typing s1 .com/api in your browser.

For more information you can refer to the official documentation. Hope my answer can help you.

Upvotes: 2

Related Questions