
{"id":8295,"date":"2021-02-24T15:41:26","date_gmt":"2021-02-24T15:41:26","guid":{"rendered":"https:\/\/rax-stg-wp-aws.com\/blogs\/configuring-a-per-site-waf-policy-with-ip-address-restriction-rules-part-three\/"},"modified":"2026-11-03T19:29:32","modified_gmt":"2026-11-03T19:29:32","slug":"configuring-a-per-site-waf-policy-with-ip-address-restriction-rules-part-three","status":"publish","type":"blogs","link":"https:\/\/www.rackspace.com\/de\/blogs\/configuring-a-per-site-waf-policy-with-ip-address-restriction-rules-part-three\/","title":{"rendered":"Configuring a per-site WAF policy with IP address restriction rules: Part three"},"content":{"rendered":"<p><strong>Introduction<\/strong><\/p>\n<p>As I mentioned in the introduction in <a href=\"https:\/\/docs.rackspace.com\/blog\/configuring-a-per-site-waf-policy-with-ip-address-restriction-rules-part-one\/\">Part one<\/a>,&nbsp;the end goal is to demonstrate how to control inbound access based on IP address restrictions&nbsp;to one of my two websites running on the Windows\u00ae virtual machine (VM).<br \/>\n<a href=\"https:\/\/docs.rackspace.com\/blog\/configuring-a-per-site-waf-policy-with-ip-address-restriction-rules-part-two\/\">Part two of the series<\/a>&nbsp;laid the foundation with the the Application Gateway configuration. Now, in this final post&nbsp;of the series, I walk through the Web Application Firewall (WAF) policy creation and test&nbsp;the custom rule. I will restrict access to&nbsp; <strong>site2.hiteshvadgama.co.uk<\/strong>. &nbsp;<\/p>\n<p><strong>&nbsp;WAF policy configuration<\/strong><\/p>\n<p>The following steps show how to create a per-site WAF policy with an IP-based access&nbsp;control rule and assign it to the Application Gateway and <strong>Site2_Listener<\/strong>, which we know&nbsp;from the earlier&nbsp;<a href=\"https:\/\/docs.rackspace.com\/blog\/configuring-a-per-site-waf-policy-with-ip-address-restriction-rules-part-two\/\">HTTP Settings section in Part two<\/a><br \/>\nis the listener that corresponds to <strong>site2.hiteshvadgama.co.uk<\/strong>.<\/p>\n<p>1. Search for <em>WAF<\/em>&nbsp;in the marketplace, select the <strong>Web Application Firewall (WAF) by Microsoft<\/strong>&nbsp;service, and click <strong>Create<\/strong>.<\/p>\n<p>2. On the <strong>Basics<\/strong>&nbsp;tab, assign the policy to the <strong>Regional WAF (Application Gateway)&nbsp;<\/strong>and fill in the rest of the basic details. Make sure the <strong>location<\/strong>&nbsp;you choose is the&nbsp;same location as the Application Gateway WAF resource. For now, I will&nbsp;<strong>disable<\/strong>&nbsp;the&nbsp;<strong>Policy state<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26707-body-Picture11.png\" alt=\"WAF Policy pic 1\" \/><\/p>\n<p>3. On the <strong>Policy settings<\/strong>&nbsp;tab, select <strong>Prevention<\/strong>&nbsp;mode. I didn\u2019t make any changes&nbsp;to the default settings in the&nbsp; <strong>Exclusions<\/strong>&nbsp;or <strong>Global Parameters<\/strong>&nbsp;section. You can&nbsp;make changes if you want to exclude specific parts of an incoming request or modify the&nbsp;request body parameters.&nbsp;<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26707-body-Picture12.png\" alt=\"waf policy pic 2\" \/><\/p>\n<p>4. On the <strong>Managed Rules<\/strong>&nbsp;tab, I kept the default <strong>OWASP 3.0 rule set<\/strong>. Depending on&nbsp;your requirements, you might want to choose a different rule set or modify the ruleset&nbsp;if certain rules are, for example, causing false positives and blocking legitimate traffic.<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26707-body-Picture13.png\" alt=\"waf policy pic 3\" \/><\/p>\n<p>5. On the <strong>Custom rules<\/strong>&nbsp;tab, I selected <strong>Add custom rule<\/strong>.&nbsp;<\/p>\n<p>\n6. I gave the rule a <strong>name<\/strong>&nbsp;and a <strong>priority<\/strong>. As a best practice, assign priority in&nbsp;increments of five to make it easier to change the order of rules in the future.<\/p>\n<p>7. For the <strong>IF<\/strong>&nbsp;statement under <strong>Conditions<\/strong>, I selected <strong>IP address<\/strong>&nbsp;as the&nbsp;<strong>Match Type<\/strong>&nbsp;and <strong>Does contain<\/strong>&nbsp;as the operation. For my test, I want the rule to&nbsp;block access if the IP address matches my local machine, so I did an IP lookup of the&nbsp;machine and added it under <strong>IP address or range<\/strong>.&nbsp;<\/p>\n<p>8. For the <strong>THEN<\/strong>&nbsp;statement, I selected <strong>Deny traffic<\/strong>&nbsp;and clicked <strong>Add<\/strong>&nbsp;to save the custom rule.<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26707-body-Picture14.png\" alt=\"waf policy pic 4\" \/><\/p>\n<p>9. On the <strong>Associations<\/strong>&nbsp;tab, I clicked on <strong>Add association<\/strong>&nbsp;and selected <strong>HTTP Listener<\/strong>.&nbsp;<\/p>\n<p>10. Because I have only one Application Gateway, it was already pre-populated.<\/p>\n<p>11. In the <strong>Listeners<\/strong>&nbsp;menu, I selected <strong>Site2_Listener<\/strong>. This is the listener associated&nbsp;with <strong>site2.hiteshvadgama.co.uk<\/strong>, which is the site I want to restrict access to.&nbsp;<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26707-body-Picture15.png\" alt=\"waf policy pic 5\" \/><\/p>\n<p>12. Click <strong>Review + create<\/strong>&nbsp;and <strong>Create<\/strong>.<br \/>\n13. After the policy creates successfully, go ahead and review it. Notice in the <strong>Overview<\/strong> blade that it is currently <strong>disabled<\/strong>.&nbsp;<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26707-body-Picture16.png\" alt=\"waf policy pic 6\" \/><\/p>\n<p>When the policy is enabled, the rule I created should check the request against the&nbsp;condition and block access from my local machine\u2019s IP to <strong>site2.hiteshvadgama.co.uk<\/strong> while still allowing access to <strong>site1.hiteshvadgama.co.uk<\/strong>.<\/p>\n<p><strong>Testing the custom rule<\/strong><\/p>\n<p>Before I enable the policy, I verify that I can currently access both <strong>site1<\/strong>&nbsp;and&nbsp;<strong>site2.hiteshvadgama.co.uk<\/strong>&nbsp;from my local machine. From the browser, I can reach the&nbsp;simple HTML page I created on each site:<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26707-body-Picture17.png\" alt=\"waf policy pic 7\" \/><\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26707-body-Picture18.png\" alt=\"waf policy pic 8\" \/><\/p>\n<p>&nbsp;Now I go and enable the WAF policy:<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26707-body-Picture19.png\" alt=\"waf policy pic 9\" \/><\/p>\n<p>When I now try to browse to <strong>site2.hiteshvadgama.co.uk<\/strong>, I get a `403` status error:&nbsp;<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26707-body-Picture20.png\" alt=\"waf policy pic 10\" \/><\/p>\n<p>However, when I browse to <strong>site1.hiteshvadgama.co.uk<\/strong>, I still have access:&nbsp;<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26707-body-Picture21.png\" alt=\"waf policy pic 11\" \/><\/p>\n<p><strong>Conclusion&nbsp;<\/strong><\/p>\n<p>This series describes how to implement a per-site WAF policy with a custom rule to an&nbsp;Application Gateway to control inbound access based on IP address-based restrictions. &nbsp;<\/p>\n<p>Custom rules are very powerful, and you can use many other variables beyond IP address&nbsp;matching to tailor rules to address-specific security policies for your web applications.<\/p>\n<p>This <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/web-application-firewall\/ag\/custom-waf-rules-overview\">Microsoft article<\/a>&nbsp;provides a great overview of the capabilities of custom rules and more advanced scenarios.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Configuring a per-site WAF policy with IP address restriction rules: Part three<\/p>\n","protected":false},"author":2,"featured_media":8297,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","format":"standard","meta":{"content-type":"","nid":"26707","content_type":"blog","created_by":"10130","authored_on":"2024-03-13T14:41:26+00:00","field_article_industries":"","tag_category":"Technical","field_blog_author_text":"Hitesh Vadgama, Solutions Architect, Rackspace Technology","seo_description":"Set up and test Web Application Firewall (WAF) policies with IP address restriction rules. Control inbound access to websites on Windows VMs.\r\n","field_featured_image":"","insights_image":"\/wp-content\/uploads\/2026\/blog_technical_images\/26707-insights_image-general-code-technical-blog-3-insights.jpg","field_partners":"","rxt_platforms":"Microsoft Azure, Security","product":"","publisheddate":"2021-02-24T15:41:26","rxt_solutions":"Multicloud, Security","opengraph_tag":"","x_tag":"","teaser_flag":"Technical Blog","seo_titile":"Configuring a Per-Site WAF Policy Pt.3 | Rackspace Technology","field_topics":"","field_slug":"configuring-a-per-site-waf-policy-with-ip-address-restriction-rules-part-three","footnotes":""},"categories":[178],"tags":[204],"class_list":["post-8295","blogs","type-blogs","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-technical"],"_links":{"self":[{"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/blogs\/8295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/blogs"}],"about":[{"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/types\/blogs"}],"author":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/comments?post=8295"}],"version-history":[{"count":3,"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/blogs\/8295\/revisions"}],"predecessor-version":[{"id":10028,"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/blogs\/8295\/revisions\/10028"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/media\/8297"}],"wp:attachment":[{"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/media?parent=8295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/categories?post=8295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/tags?post=8295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}