0
votes

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)

1
Did you use the FB debug tool to clear the cache?CBroe

1 Answers

1
votes

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>