ARR (Load Balancing Mode) only shows 404 - http-status-code-404

Preamble:
I have 3 windows 2016 vms with IIS
IIS04 - the ARR server (arr.mytestapp.com)
IIS10 - the 1st load balancing target (host1.mytestapp.internal)
IIS11 - the 2nd load balancing target (host2.mytestapp.internal)
From the ARR server, i can browse to both hosts (the app loads)
For the farm setup, i have added both servers and this URL test
http://arr.mytestapp.com/status.aspx
Response Match = [Online]
which tests successfully - both servers pass
The Issue
When i browse to the arr url, it gives me "HTTP Error 404. The requested resource is not found"
I've enabled failed request tracing rules, but cant see much in there that's obviously wrong. The rewrite rules are using the name of the farm... not sure if this is a problem
<EventData>
<Data Name="ContextId">{80000015-0001-FF00-B63F-84710C7967BB}</Data>
<Data Name="Substitution">http://mytestapp.website/{R:0}</Data>
<Data Name="RewriteURL">http://mytestapp.website/favicon.ico</Data>
<Data Name="AppendQueryString">true</Data>
<Data Name="LogRewrittenURL">false</Data>
</EventData>
<EventData>
<Data Name="ContextId">{80000015-0001-FF00-B63F-84710C7967BB}</Data>
<Data Name="OldUrl">http://mytestapp.website/favicon.ico</Data>
<Data Name="NewUrl">/favicon.ico</Data>
</EventData>
I'm guessing this has something to do with my URL Rewrite rule... but I'm stumped.
<rule name="ARR_mytestapp.website" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<action type="Rewrite" url="http://mytestapp.website/{R:0}" />
<conditions>
<add input="{HTTP_HOST}" pattern="*.mytestapp.com" />
<add input="{HTTP_HOST}" pattern="api.mytestapp.com" negate="true" />
</conditions>
</rule>
Any help would be greatly appreciated

So, if you have multiple sites setup on the same server, you need to add the ARR servers host header into each web servers host headers. It appears that ARR preserves the host header of the original request.
so for my setup, I now have the following. This resolves the 404 error
Site Bindings
ARR Server
arr.mytestapp.com
Web Host 1
host1.mytestapp.internal
arr.mytestapp.com
Web Host 2
host2.mytestapp.internal
arr.mytestapp.com

Related

how can i host react app in IIS web server?

How can i host reactjs app in IIS webserver?
I used npm run build and replaced the file into the server and create new site which refers to those file.
also i add the binding all IP to port 80 using * sign.
but not worked.
After we run the below command, the output will create a new folder called “build” inside the project which contains production build. We could host the project by copying these files to the root directory of the IIS website, the website root folder should be able to be accessed properly by the anonymous account, and therefore we should grant IUSR account full access to the folder if it is not the default website.
After adding the web site binding in IIS binding module,
We could access the website properly by using the below address.
http://localhost
Besides, if we adding certain routing features (multiple components) in the react application, we have to install the IIS URL Rewrite extension.
https://www.iis.net/downloads/microsoft/url-rewrite
After a successful installation, we need to create a web.config file containing the below content under the root directory of the IIS website.
<?xml version="1.0"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="React Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Feel free to let me know if the problem still exists.

In a DotNetNuke site how do I bypass a 404 error?

I have a site -- example.com. It has static pages -- example.com/signup, example.com/faq, etc.
However, I want to be able to have "example.com/some-search-term". Of course, there is no page "some-search-term".
I tried installing a custom module on the 404 error page that would take the query string and display some info based on that search criteria. However, I still get a 404 error "HTTP404: NOT FOUND - The server has not found anything matching the requested URI (Uniform Resource Identifier).
GET - http://example.com/some-search-term." and the page is blank.
I can debug my module when the 404 page is triggered and see that everything is working fine but the final results are not displayed.
Any ideas?
For something like this I would suggest using IIS rewrite rules or rewritemaps. You can do this via the web.config or separate files that the web.config points to. If you setup a redirect for each term, you'll be good to go.
EG: in Web.config
<rewrite>
<rewriteMaps configSource="fmrewrites.config" />
<rules configSource="fmrules.config" />
</rewrite>
And within the fmrewrites.congig
<?xml version="1.0" encoding="utf-8"?>
<rewriteMaps>
<rewriteMap name="FmRedirects">
<add key="www.siteexample.com/," value="https://www.siteexample.com/" />
</rewriteMap>
</rewriteMaps>
Or within the fmrules.config
<?xml version="1.0" encoding="utf-8"?>
<rules>
<clear />
<rule name="FmRewrites" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{FmRedirects:{HTTP_HOST}{REQUEST_URI}}" pattern="(.+)" ignoreCase="true" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" />
</rule>
</rules>
You can read up on a lot of this via MS Docs.
I solved this a different way.
DNN provides a default 404 page. I simply added a custom module that evaluates the status code on Page_Load():
_rcode = Response.StatusCode;
if (_rcode == 404) //we're on our 404 page
{
Response.Clear();
Server.ClearError();
}
The module then does a few database lookups on the query string to see if there are any matches. If there are, it redirects to the appropriate page. If nothing matches, then I generate a 404 error.
I was trying to keep everything on the 404 page but I couldn't. Since the page "example.com/some-search-term" doesn't actually exist, some page components aren't available -- IsPostBack, ViewState, Session, etc. -- so it was difficult to generate a page that worked. Even setting the Response.StatusCode to 200 did not work.
Ultimately, I was trying to prevent google from seeing a 404 error unless I wanted it to. This seems to have worked.

IIS rewrite rule for Facebook share dialog doesn't work

I have the following rule
<rule name="SEO" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_USER_AGENT}" pattern="(facebookexternalhit)|(facebook)|(Twitterbot)|(Pinterest)" />
<add input="{QUERY_STRING}" pattern=".*escaped_fragment_=(.*)" />
</conditions>
<action type="Rewrite" url="http://localhost:8004/{URL}" />
</rule>
of my angularJS app hosted on the IIS (Windows Server 2012).
My app uses the html5Mode
$locationProvider.html5Mode().enabled = true;
and the port 8004 is opened (I turned off Windows firewall for a while to check if my scenario works)
The scenrio is easy. When someone wants to share my AngularJS page via facebook, the request will be redirected the the port, whene the PhantomJS is listening on (to render the page)
But the problem is I can only see the 404 error in the share box, and no request is fetched by the phantomJS script (I don't see anything in the console window)
var system = require('system');
var server = require('webserver').create();
server.listen(port, function (request, response) {
console.log(JSON.stringify(request, null, 4));
});
so it looks like the rewrite rule doesn't work (that's my guess). If I just go to the http://localhost:8004/, I can see the rendered page and the phantomJS log in the console window (so it works)
If you are trying to rewrite requests to different IIS website (or different app), then before that you need to install ARR:
1) You need to install ARR module https://www.iis.net/downloads/microsoft/application-request-routing
2) In IIS manager you should enable reverse proxy
2.1) On server node click "Application Request Routing Cache"
2.2) Click "Server proxy settings" and click "Enable proxy", then "Apply"
Also you need to apply small fix in your rule:
<rule name="SEO" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_USER_AGENT}" pattern="(facebookexternalhit)|(facebook)|(Twitterbot)|(Pinterest)" />
<add input="{QUERY_STRING}" pattern=".*escaped_fragment_=(.*)" />
</conditions>
<action type="Rewrite" url="http://localhost:8004{URL}" />
</rule>

Azure AngularJS Index.html

My AngularJS app requires all actions to redirect to index.html for processing and it works fine on localhost, but it doesn't work in Azure.
For example:
localhost:1234 -> localhost:1234/#/ works
myapp.com -> myapp.com/#/ doesn't work
myapp.com/index.html -> myapp.com/index.html#/ works
I added:
<system.webServer xdt:Transform="Replace">
<rewrite>
<rules>
<rule name="redirect all requests" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="index.html" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
The weird thing is that this works sometimes. I can't for the life of me figure out why sometimes going to myapp.com -> myapp.com/#/ works and other times it doesn't. It seems to also break myapp.com/index.html#/ but only sometimes. This is without making any deployment changes. It just works about half the time.
Edit
Here is the actual error message:
Microsoft.Owin, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
It might be about application startup. Here are some troubleshooting ideas.
Restart your app. Does that reliably cause the error?
Turn on application logging. portal.azure.com > Browse All > The Site Name > Settings > Diagnostic logs > Application Logging > Level Error. If you want lots of stuff, set level to verbose and turn on web server logging, detailed error messages, and failed request tracing.
View diagnostics at service control manager mysite.scm.azurewebsites.net. Choose Debug console > PowerShell. Now you can look through the logs at home/LogFiles.
Based on the error you are receiving, it looks like Owin is the problem. Check your websites bin to see if there are any Owin references. From the online service control manager, you can try this:
cd site/wwwroot/bin
Get-ChildItem -filter *Owin*
If there is anything there, then it's probably the cause of the particular error you are receiving.

Angular JS with facebook sharing

URL not redirecting to Prerender.io when sharing the url from facebook.
My site is http://www.vbuy.in/ , which is in demo and I am trying to share one of the url in facebook for example "http://www.vbuy.in/product/samsung-galaxy-grand-2-black-/1975"
Title and Description are showing from the home page (I added all those supported ng-content, and in script i registed the viewtitle etc..
I wrote a URL rewrite and also tested in https://developers.facebook.com/tools/debug/og/object/.
But, for me it looks like its not redirecting to prerender.io url. What Am I missing here? . I use IIS and also downloaded ARR and enabled proxy there.
I am having tough times for the last one week with SEO & social sharing part. Even before starting the project we were aware of SEO issues in angular js, but we thought when we go
live, we can use prerender or any pre render static html support. ( we didnt evaluated in depth earlier, due to time & resource constraints)
My code .. (Which is copied from other Stack overflow solutions.
<httpProtocol>
<customHeaders>
<add name="X-Prerender-Token" value="XXXXX....." />
</customHeaders>
</httpProtocol>
<rewrite>
<rules>
<rule name="Prerender" stopProcessing="true">
<match url="^(?!.*?(\.js|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.gif|\.pdf|\.doc|\.txt|\.ico|\.rss|\.zip|\.mp3|\.rar|\.exe|\.wmv|\.doc|\.avi|\.ppt|\.mpg|\.mpeg|\.tif|\.wav|\.mov|\.psd|\.ai|\.xls|\.mp4|\.m4a|\.swf|\.dat|\.dmg|\.iso|\.flv|\.m4v|\.torrent))(.*)" ignoreCase="false" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_USER_AGENT}" pattern="googlebot|baiduspider|facebookexternalhit|twitterbot" />
<add input="{QUERY_STRING}" pattern="_escaped_fragment_" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="http://service.prerender.io/http://www.vbuy.in/{R:1}" />
</rule>

Resources