I have created a block rule for my website where I'm listing a few IP-addresses that are allowed to access the Admin-page of my website. The condition looks like this:
<xsl:template match="/configuration/system.webServer/rewrite/rules/rule[@name='adminBlockRule']">
<xsl:comment>Blockera Admin för alla utom vissa IP-adresser</xsl:comment>
<rule name="adminBlockRule" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^(Admin/|Sysadmin/).*$" ignoreCase="true"/>
<conditions>
<xsl:comment>Generell</xsl:comment>
<add input="{REMOTE_ADDR}" pattern="10.*.*.*" negate="true" />
<add input="{REMOTE_ADDR}" pattern="194.103.31.*" negate="true" />
... More rules
</conditions>
<action type="AbortRequest" />
</rule>
<xsl:comment>Hit</xsl:comment>
</xsl:template>
When I put it in my web.config file it works fine, but when I put it in my web.production.config-file and run it with XSLT it removes the "{REMOTE_ADDR}" so the output looks like this:
<rule name="adminBlockRule" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^(Admin/|Sysadmin/).*$" ignoreCase="true" />
<conditions>
<!--Generell-->
<add input="" pattern="10.*.*.*" negate="true" />
<add input="" pattern="194.103.31.*" negate="true" />
</conditions>
<action type="AbortRequest" />
</rule>
Anyone know how to fix this problem?
I'm using version:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:saml="urn:dk.nita.saml20.configuration"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl saml">
<xsl:output method="xml"
indent="yes"/>
<xsl:strip-space elements="*"/>
I solved my question by adding a extra pair of "{}" in the input parameter and that did the trick. New conditions looks like this:
<add input="{{REMOTE_ADDR}}" pattern="10.*.*.*" negate="true" />
<add input="{{REMOTE_ADDR}}" pattern="194.103.31.*" negate="true" />