ARR Requests Not Properly Routing to Server Farm - iis

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.

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.

What steps are required to make ColdFusion websockets work on an Azure VM behind Cloudflare?

We are attempting to use websockets in ColdFusion (2018.0.13.329786) in an app we have running on Azure VMs behind Cloudflare. However, we are continually getting this error on the client side:
WebSocket connection to 'wss://www.*************.com/cfws' failed:
CFWebSocketWrapper.open # cfwebsocketCore.js:21
init # cfwebsocketChannel.js:49
_cf_websockets_init_6539553945348401 # strategies-for-devel…ing-with-impact:175
fire # cfajax.js:1214
$E.windowLoadHandler # cfajax.js:1321
Uncaught TypeError: Cannot set properties of undefined (setting 'readyState')
at WebSocket.wsConnection.onerror (cfwebsocketCore.js:54:29)
wsConnection.onerror # cfwebsocketCore.js:54
error (async)
CFWebSocketWrapper.open # cfwebsocketCore.js:53
init # cfwebsocketChannel.js:49
_cf_websockets_init_6539553945348401 # *************:175
fire # cfajax.js:1214
$E.windowLoadHandler # cfajax.js:1321
load (async)
$E.onWindowLoad # cfajax.js:1297
cfinit # cfajax.js:1332
(anonymous) # cfajax.js:1834
We have a cfc that's called when a message is posted to a channel that writes to a log file on the server, and this log file never gets updated. This is unsurprising as it appears that something is preventing the connection altogether.
From a configuration perspective, we run these updates when the VM is created:
webSocketObj= createObject("component","cfide.adminapi.websocket");
webSocketObj.setProperty(propertyName="EnableWebSocketServer", propertyValue="true");
webSocketObj.setProperty(propertyName="EnableProxyPort", propertyValue="8581");
and then via cfExecute:
#server.coldfusion.rootdir#/lib/wsproxyconfig.jar -ws IIS -site All -host localhost -port 8581
and then the CF service and IIS are restarted.
We have also enabled the websocket 'switch' in Cloudflare.
This should be the same as going into CF Admin, going to the websockets tab, and then ticking "Use Proxy", and then using the default port of 8581. This should send everything through IIS on port 443 from the client perspective.
Cloudflare and Azure say that no special configuration is needed. And we can see that CF has port 8581 open.
The most infuriating thing is that we worked on this in our Dev environment last year and after much trial and error got it working. However, our notes from that time were not good and when we did the above to try to get this working in our QA environment it did not work. We're obviously missing a step somewhere, but have not been able to figure it out.
Can anyone who has gotten this working explain what steps are required to make ColdFusion websockets work on an Azure VM behind Cloudflare?
We solved this issue. Hopefully this will help anyone else who runs into the same problem:
Per this doc, we realized that the wsproxyconfig was supposed to be creating an 'application' (like a virtual folder) in IIS called cfws pointing to <CF_INSTALL_HOME>/config/wsproxy/1. However, it was not doing so. Once that application was created, everything started working as expected.
Upon further testing we found that it created this application only if it was run as administrator. Otherwise, it reported success and provided no warnings or failures, but did not create the application.
We were running wsproxyconfig from the command line via CFExecute, so it was running under an administrative user, but that was apparently not sufficient. So we moved the wsproxyconfig call to one of our PowerShell scripts and had it run with administrative privileges and that solved our problem.
This had apparently worked in our dev environment originally because we ran wsproxyconfig manually.

IIS possibly caching the status of the Active Directory server

We have a situation where if the Active Directory server has a temporary problem possibly a network/DNS glitch, then after it is fixed the web application running under IIS still receives this error:
"The server could not be contacted. at
System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)"
This situation clears when IIS is reboot or we run iisreset.exe.
Could it be that IIS is caching the status of the downed directory server. In which case how can we avoid that?

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.

IIS Took Over My Port 80 and I Can't Get it Back! [Windows Server 2008; Trying to run TeamCity]

Prologue: I am running windows Server 2008 R2 on a Virtual Machine. This virtual machine image has been happily hosting TeamCity on port 80 for several weeks. This TeamCity server is accessed by others on the network by visiting a url (pcname.domain.com).
The Issue: It seems corporate decided to push some updates to my machine over the weekend. It seems this round of updates decided to install/update IIS. Low and behold, visiting the URL mapped to the TeamCity server actually takes me to the stock IIS7 page. Visiting url/login.html brings me to the TeamCity log-in page.
Attempts: First off, I changed the TeamCity port to 8080 and was able to access it at url:8080 (or localhost:8080). However, it is imperative to me that people can access the server without providing a port... so I change TeamCity server port back to 80 and set off to try and fix this IIS problem.
Since then I have uninstalled IIS7 by removing the role and services from Windows - I am now hosting "0 roles". I have removed every trace of IIS from my PC, but visiting localhost still gives me 404 not found (instead of server not found or just my TeamCity page).
My Question: How do I prevent Windows Server 2008 from trying to host some default crap on port 80 so that my TeamCity server can be seen again?
EDIT: After performing netstat -ano, the only PIDs associated with port 80 are '0' and '4' (system and svchost!)
In windows the usual suspects using port 80 are IIS itself, and maybe the Web Deploy Agent Service if installed (but it could have any other app bound to that port). The PIDs 0 and 4 just tell you that the applciation using that port is running as a service. If you do not need any of this (IIS, web deploy, etc), go to Services and disable them, the port should be free to bind after that.
You can use net sh http show servicestate | findstr HTTP to reach the address and port binding information.
A simple solution (one that I am also using in a production server with multiple apps) is to set up a proxy based on either the domain or the URL path itself (see here how to with nginx).
Hit command, netstat -ano in an elevated command prompt to see what applications are listening on which ports. This command will show you the PID of the process that is listening on port 80. Now, open the Task Manager -> Processes tab. From the View -> Select Columns menu, enable the PID column, and you will see the name of all the processes those are listening on port 80. You can kill the listed tasks. Mostly applications like, World Wide Web Publishing service, IIS Admin Service, Web Deployment Agent Service may use the port 80 in Windows Operating System.

Resources