Server Fault Asked by Dean Christian Armada on December 23, 2021
I have an IIS Server that originally hosts static HTML in wwwroot but then we decided that if a Baidu Spider tries to crawl we will map the traffic to our NuxtJS Web Server running also beside the IIS Server.
So we installed ARR (Application Request Routing) to enable the reverse proxy it is working fine and now we tried to test first where in URL Rewrite Inbound Rule:
So with that we expect that if common users requested then it will serve the static HTML in wwwroot instead since it did not hit a rule but instead I got a 500.
TAKE NOTE:
So do I need to create another rule? I was expecting that if it did not hit any rule the default behaviour for which it just reads in wwwroot will happen
UPDATE
<?xml version="1.0" encoding="UTF-8"?>
<rules>
<clear />
<rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="false">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:3000/{R:1}" />
<conditions>
<add input="{HTTP_USER_AGENT}" pattern="^((?Baidu).)*$" />
</conditions>
</rule>
<rule name="StaticHTMLForBaiduCrawler" enabled="true" stopProcessing="false">
<match url="(.*)" />
<conditions>
<add input="{HTTP_USER_AGENT}" pattern="^((?!Baidu).)*$" />
</conditions>
<action type="Rewrite" url="{R:1}/index.html" />
</rule>
</rules>
The regular expression in the condition in your first rule is not a valid regex for IIS. If you want the first rule to be hit when the user agent contains Baidu and the second when it does not then you can just do something like below. Note the negate in the condition in the second rule:
<?xml version="1.0" encoding="UTF-8"?>
<rules>
<clear />
<rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="false">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:3000/{R:1}" />
<conditions>
<add input="{HTTP_USER_AGENT}" pattern="Baidu" />
</conditions>
</rule>
<rule name="StaticHTMLForBaiduCrawler" enabled="true" stopProcessing="false">
<match url="(.*)" />
<conditions>
<add input="{HTTP_USER_AGENT}" pattern="Baidu" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}/index.html" />
</rule>
</rules>
Answered by Jeroen on December 23, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP