Application Request Routing Rule to manage requests on 2 servers - iis

I have only 2 Servers (windows server 2019), setup their IPs (172.10.10.2 & 172.10.10.3)
I Installed ARR on Server 1
I want Server 1 as Content Server as well (due to limited resources)
I deployed Sample Application on server 1 and server 2
Set the Load Balance Algorithm as "weighted round robin" with even distribution.
The Default rewrite rule mostly display server2 application and if the browser request on server 1, it gives error "Bad Request".
what is solution for that, what should be the custom rule to fix the problem?

Related

Redirect all requests from one server to another

I have two servers, Server 1 (A Windows Server VPS) and Server 2 (A Linux VPS).
Both servers are running NodeJS API using PM2 without anything like apache or nginx or whatever.
What I want is to redirect all requests from Server 1 to Server 2 because I want to shut Server 1 down after a while.
Server 1 address: www.pharmart.sy
Server 2 address: www.pharmartco.com
I don't want to redirect using the res.redirect method because that would break my application.
The application is a Mobile Application that's why I don't want to use the res.redirect method, and I have the link to the server hardcoded in the app so I need to upload another version of it in order to change the link to the second server. I also can't make sure that everyone updates the app and that's why I need to redirect all the requests to the second server.
So all the redirection handling should be done on the Windows machine.
What is the best way of doing that?
Here are a couple ideas:
DNS
Change the DNS for the server 1 domain to point to the server 2 host. So, then all requests to either DNS name will go to server 2. You may have to wait a little while until any local DNS caching effects time out. An advantage of this approach is that while you are waiting for DNS caching effects to expire, everything stays up as requests either go to a working server1 or a working server2. When cached DNS has finally expired, all requests will be going to server2 and you can then take server1 down.
Your Proxy
You could replace the current server 1 process with a proxy that points to server 2. So, any requests incoming to server 1 will be proxied over to server 2. Since a change like this probably can't be made instantly, you might have a short amount of downtime for requests coming into server1.
Hosting Proxy
If this is running at a hosting provider, then they probably have a proxy service already running that proxies your public DNS IP address to your actual host. That hosting proxy could be reconfigured to direct requests for server1 to server2 instead.

ARR Requests Not Properly Routing to Server Farm

I have installed ARR on my Windows 2019 server via the IIS Platform Installer and configured it by adding a server farm and adding a single server to it.
I can ping the server and ARR shows it is online. The issue is, when I submit a request from my local PC, it seems to hit the ARR server but it never hits the server farm. The browser returns 404 Not Found.
On the ARR server, if I create a request to "controlcenter.mydomain.com" and view the logs in C:\iislogs\www\HTTPERR I see this error:
2020-10-30 19:14:54 [my local computer IP address] 53391 [my ARR server IP address] 80 HTTP/1.1 GET / - 404 - NotFound -
The sites on my webfarm server are "controlcenter.mydomain.com" and "api.mydomain.com." Do I need to create special rewrite rules for these sub domains? I cannot seem to tell from the documentation.
How can I find out why the request is not being properly routed from the ARR server to the server I've added to my server farm (shown below)?
When I tried to reset runtime statistics on the Monitoring and Management page, it says, "The operation could not be completed because the worker process has stopped."
The health test with URL "http://controlcenter.mydomain.com" succeeds also.
Before you use ARR, you must first make sure to create a site bound to your domain, and then ARR can forward requests for that domain to the server farm.
In order to solve the problem of stopping the work process, there are the following methods.
Setting Ping Enabled to False stops IIS from checking whether the worker process is still running and keeps the worker process alive until you stop your debugged process. Setting Ping Maximum Response Time to a large value allows IIS to continue monitoring the worker process. You can refer to this document.
Run this command from the elevated command prompt on the controller machine.
net stop webfarmservice & cd /d "%programfiles%\iis\Microsoft Web Farm Framework" & mkdir extensions & move WFFExtension.dll extensions & net start webfarmservice
When I tested in my environment and killed the w3wp.exe, health test returned success but status of servers were unknow. This command solved the issue.
Delete the server farms and restart the IIS, then re-create server farms and add servers.

Azure load balancer identify server

we have two VM (classic) in an availability set and via end points defined load balancer on port 80.
Each VM has 5 websites running and the load balancer distributes calls between server 1 and server 2
When I call one of the websites, e.g. www.mysite.com is it possible somehow to identify which server has served the request?
Is it possible to force load balancer to ping a specific server? This can be super useful when we deploy a new version of the website e.g. on Server 1 and we want to test does it work on Server 1
thanks
I would include an header "Server :" in my response : rfc2616-sec14.. Then you are able to check it via Chrome Developer Tools (Network) or any other similar tool.
At the end, I've figured out how this can be done. Hopefully, my answer will be useful to someone with a similar problem
-Identifying servers, as ArneRie has suggested, can be done by adding a custom HTTP header response - https://technet.microsoft.com/en-us/library/cc753133(v=ws.10).aspx
Call specific server
In the Azure portal create a new endpoint, e.g. 802 ->8181.
RDC to the server open port 8181
Install port forwarding utility https://sourceforge.net/projects/pjs-passport/
Set a new rule: all traffic coming from 8181 should be redirected to 80 (as the source port use internal server IP)
Call www.mysite.com:802 and it will be served from the specific server
Repeat steps 1-4 with another server just use a different port e.g. 801, 803...

Application Request Routing - Single server webfarm setup in IIS

I'm trying to setup Application Request Routing (v2.5) on my Windows Server 2008 with IIS 7.5.
So far I got this:
IIS 7.5 running two sites
www.domain1.com
test.domain1.com
IIS 7.5 with a webfarm called My-Farm with one server: test.domain1.com
Apache Tomcat running some server on www.domain1.com:10000
I'm able to route requests coming to www.domain1.com to the webfarm but I don't see any result coming from test.domain1.com?
I also tried changing servers at step 2 above to localhost or www.domain1.com:10000 or localhost:10000 but whatever I do the requests aren't proxied.
Am I setting ARR up correctly?
In ARR, when hosting the sites locally in the same server as ARR, I tend to split the public facing sites (receiving the requests) from the proxied sites.
In your case your could have something like this:
IIS:
- Site 1 (binding: test.domain1.com:80)
- Site 2 - proxied (binding: 127.0.0.1:22001)
Rewrite Rule
- Match All
- {HTTP_HOST} matches test.domain1.com
- {SERVER_PORT} does not match 22001
- Action: Route to Far
This way, requests arriving to Site 1 are routed to Site 2 when requesting test.domain1.com. The port change and the rule avoid ARR routing requests to site 2 again.

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.

Resources