IIS site application as proxy to another application on different server - iis

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
WWW app is available on https://s1.com
WWW app connects to API at https://s1.com/api
WWW send request to 's1.com/api' --request-> to 's2.com/api' --respsnse-> 's1.com.api' --response-> WWW.
Is is possible to do this on IIS?

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.
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.
4.Select the website(here listening on port 8082) and double-click URL Rewrite to open the feature.
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.
6.At this point, a ReverseProxyInboundRule will be automatically generated, and you can modify the rules according to the actual situation.
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.

Related

how to use IIS redirect to send requests to node in another port

I am using windows server 2008 R2 standard and I have installed a node.js app that runs fine in port 3000.
In windows server, the admin used ISS to create a Default Web Site , so the port 80 is open to everyone. This works fine, I go to mywebsite.com and I get the ISS7 logo.
I cannot run the node app directly on port 80. I have to use a proxy to send traffic from mywebsite.com:80 to localhost:3000. (is it localhost? I guess it is)
I try to do this by using Application Request Routing. According to this tutorial
I install ARR and create a new server farm named "redirect".
I put windows server IP as the server address, click advanced settings, click applicationRequestRout, change httpPort to 3000 (my node app) and hit Finish
So now the server farm named redirect represents my node on port 3000 , right?
I go to server farms > redirect > servers, double click on the one server on the list and hit Connect to the server
Click URL rewrite, Add Rule, Blank Rule under Inbound Rules
I name it "redirecctrule", pick "Wildcards" under Using and then hit Test pattern.
I put /* in Input data to test and /* in pattern (wildcard), so everything that comes from mywebsite.com can go to node , port 3000, right? Maybe here is my mistake? I dont know.
Then I hit Test, the test is ok, so I close and hit Yes to Save that rule. I also pick "Route to server farm" under Action and hit Apply on the right.
Node is running. If I go to mywebsite.com on my browser, I still get the ISS logo, not the website from node. I restarted the server and tried again, still nothing.
What am I missing here? How can I redirect traffic from ISS Web Site port 80 to node app, port 3000?
Any advice would be great, I am trying all day and it does not work.
Thanks

Want to have app (Server:Port) to have friendly alias - Understanding Host Alias / DNS / A Record / CNAME

I am trying to get my head around Windows, Networks and Domains.
I currently have a server - svr. This is on my domain companyname.co.uk
I can connect to server and ping both svr and svr.companyname.co.uk.
On this server I have a number of applications with web access; TeamCity, Octopus etc. We currently connect to them by browsing to svr:xxxx where xxxx is the port of the web app host (http://svr:9090/ for TC)
I want to create friendly alias' - for example teamcity.companyname.co.uk would point at svr:9090, octopus.companyname.co.uk would point to svr:8090.
However, not being experienced in this area I can't seem to find relevant documents or sites that fully explain what I am looking for.
First, to make one thing clear: when you visit a web page like http://example.com, your web browser is actually making a request to example.com:80. This is done transparently because port 80 is the standard port for the HTTP protocol. As you know, you can request a non-standard port by appending it to the domain name in the URL: http://example.com:888/.
Unfortunately, you cannot have a domain name "alias" that somehow includes a non-standard port - your browser will always try to use port 80 if you don't specify a port.
One solution would be to use a proxy - nginx, apache, lighttpd, and others can all do this.
The idea is that you set up a proxy server that is listening on port 80 on your host. It waits for connections, then forwards those connections to a different server (on the same host, or on a different one) based on some rule. So, for example, you might have rules that look something like this:
IF host = teamcity.companyname.co.uk THEN forward to teamcity:9090
IF host = octopus.companyname.co.uk THEN forward to octopus:8090
The syntax for these rules vary widely between different proxy configurations, so this is just an example.
Note that this is not a redirect - the user's browser connects to teamcity.companyname.co.uk for all requests. It's the proxy that sends the request on to a different service and forwards any responses back to the client "behind the scenes".
These proxy configurations can get quite complex. For example, what if your teamcity application serves a page with a link on it that points to http://teamcity:9090/path/to/page? The user's browser is going to fail if they click on that link. Fortunately, proxies can be configured to rewrite URLs like this on the fly. You'll need to do some research to tailor this solution to your situation.

IIS8 Reverse Proxy - Custom external port

I am trying to configure my IIS reverse proxy to route http connections to an internal server however I am not sure how to achieve what I need or even if it is possible.
I have a sub domain on my IIS server for example,
testing.contoso.com and externally I would like to have http://testing.contoso.com:8080 which will then map to my internal server http://server04.contoso.local:8080. So I do not want my internal site to appear as http://testing.contoso.com on port 80.
My reason for doing this is that I will have quite a few internal and external corresponding ports.
Is it possible to configure this with my IIS reverse proxy or does IIS only support ports 80 & 443 externally?
Thanks in advance, Neil
From what I see in your question, it should be fairly easy to make that work using IIS Application Request Routing: http://www.iis.net/downloads/microsoft/application-request-routing
That should let you use any ports or hostnames in a machine being exposed and then let that route to any other machines (or same) in any ports or combination. It also will allow you to offload cache of static files, and many other nice features. It uses URL Rewrite for the main engine on which server to route to, so you can literally add any logic you want, and if need be you could use extensibility of URL Rewrite to add custom code to define the logic (though the built-in configuration one should be rich enough).

How to configure ARR - Application Request Routing - to run both as web server applications and as as a reversed proxy?

I have this IIS7.5 with ARR installed on and configured as a reverse proxy to another server which is running IIS7.
On this IIS7.5 I have ASP.NET 4 applications and simple websites installed.
Since configuring a farm on this IIS7.5 running it as a reversed proxy, the local application doesn't run with this error message:
502 - Web server received an invalid response while acting as a gateway or proxy server.
There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.
Will it be possible to run both local application and routing (reverse proxy) on this IIS7.5 at the same time or should I give up and move the applications to other servers?
Application request routing operates as a server-wide URL-rewriter.
This means that it captures all traffic coming to a box.
You can still host an IIS website on the same box, but you need to make sure that ARR leaves the requests for this site alone.
I set this up so that the ARR rule, while still remaining a wildcard *, I make sure that part of the match conditions is for requests to my local site to be left alone.
There are a number of conditions you can use to create a does not match rule.
Ive used:
{HTTP_HOSTNAME} if you are just doing HTTP requests and just want certain domain names to be left alone.
{SERVER_PORT} if you're hosting an SSL site and are the only one on the box.
{LOCAL_ADDR} if your site sits on a dedicated IP address.
many more.... really you just need to set up rules that exclude your locally hosted website.

How to configure Application Request Routing in IIS 7.0 for 2 applications running locally on different ports?

I've got 2 applications running on my local machine. One sharepoint and another IIS application:
localhost:43442
localhost:5080
I've installed ARR and need to configure it to run these 2 apps on a host and port but when adding a new server, it only accepts a server name rather than its port as well.
Any help?
For me, I needed to add a server to my server farm, called localhost. Clicking Advanced Settings... lets you specify the http and https ports. Set those to the ports that you would like your domain proxied to.
After that, create an inbound rule for URL Rewrite that matches the HTTP_HOST condition with a pattern of your website domain that the server is acting as a proxy for. Select Route to Server Farm for the action and select the specified server farm.
I added a new Inbound Rule and it worked :)

Resources