IIS - URL Rewrite Using IP Restrictions

Phill Berry 1 Reputation point
2022-08-16T13:45:40.307+00:00

Hi folks,

I have recently entered the world of IIS and one of the first things I picked up is the URL Rewrite module, I've used it for all sorts of rewrites and feel fairly comfortable until I picked up this query.

I am using Umbraco and wish to hide the umbraco login page based on IP addres so that a small set of IP addresses can still see it. I've scoured Google and various forums trying different methods, the simplest seems to be the following, bearing in mind I also have load balancing in the mixture hence the use of HTTP-X-FORWARDED-FOR.

Here is my example, if anyone could offer advice, I have also tried 'escaping' the IP addresses using . but this made no difference:

<rule name="Allowed IPs" enabled="true" patternSyntax="Wildcard" stopProcessing="true">   
<match url="*" />  
<conditions>  
<add input="{URL}" pattern="/Umbraco/*" />  
<add input="{URL}" pattern="/Umbraco/surface/*" negate="true" />  
<add input="{URL}" pattern="/Umbraco/cms-api/*" negate="true" />  
<add input="{HTTP_X_FORWARDED_FOR}" pattern="127.0.0.1" negate="true" />  
<add input="{HTTP_X_FORWARDED_FOR}" pattern="***.***.***.***" negate="true" />  
</conditions>  
<action type="CustomResponse" statusCode="404" statusReason="Access Denied." statusDescription="Access Denied." />   
</rule>  
Windows development Internet Information Services
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sam Wu-MSFT 7,561 Reputation points Microsoft External Staff
    2022-08-17T02:36:54.783+00:00

    @Phill Berry

    wish to hide the umbraco login page based on IP addres so that a small set of IP addresses can still see it

    IP Address and Domain Restrictions can fully meet your needs, more information about how to use Dynamic IP Address Restrictions you can refer to this link:

    Dynamic IP Address Restrictions.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

  2. Wine History Tours 1 Reputation point
    2022-08-25T06:33:20.167+00:00

    Thank you for your help Sam, it turns out there was another web. config file nested in the umbraco build that what to expect at a tasting room conflicting with my changes.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.