{"id":10080,"date":"2025-12-15T04:41:47","date_gmt":"2025-12-15T04:41:47","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=10080"},"modified":"2025-12-15T04:41:49","modified_gmt":"2025-12-15T04:41:49","slug":"apache-restrict-access-by-ip","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/","title":{"rendered":"How to Restrict Access by IP in Apache Server"},"content":{"rendered":"\n<p>Apache web server is used by millions of websites and blogs. So it is a common target of attacks by hackers. System administrators often need to restrict access by IP in Apache server. But they are often confused with the sheer number of options available in Apache, for this purpose. In this article, we will learn how to allow or deny requests from one or more IP addresses to an Apache server.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#Why_Restrict_Access_By_IP\" >Why Restrict Access By IP<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#How_to_Restrict_Access_by_IP_in_Apache_Server\" >How to Restrict Access by IP in Apache Server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#1_Using_Apache_Configuration_File\" >1. Using Apache Configuration File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#2_Using_htaccess_file\" >2. Using .htaccess file<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#Points_to_Remember\" >Points to Remember<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_Restrict_Access_By_IP\"><\/span>Why Restrict Access By IP<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>There are several reasons why you may need to restrict access in Apache server:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Security<\/strong> &#8211; These days, many sites and applications are falling prey to <a href=\"https:\/\/www.cloudflare.com\/learning\/ddos\/what-is-a-ddos-attack\/\" target=\"_blank\" rel=\"noreferrer noopener\">DDOS (Distributed Denial of Service)<\/a> and Brute Force attacks, which overwhelm web server and bring down a site. There are also well-known malicious bots that attack vulnerable sites. In such cases, you have to block IPs that cause these problems.<\/li>\n\n\n\n<li><strong>Access Control<\/strong> &#8211; You may need to restrict your site or its content in certain geo locations (e.g., countries, states, etc.). You may need to restrict certain sites in your organization such as corporate office and schools. You may also need to prevent automated bots from scraping data off your site. In all these cases, you need to restrict access by IP.<\/li>\n\n\n\n<li><strong>Behavioral Control<\/strong> &#8211; Sometimes you may need to ban requests from certain IP addresses, if they violate your site&#8217;s terms and conditions. You may also need to block them if they are sending too many requests unnecessarily.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Restrict_Access_by_IP_in_Apache_Server\"><\/span>How to Restrict Access by IP in Apache Server<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>There are mainly two ways to control access in Apache server. The older Apache versions (&lt;2.4) use Allow statement to allow access from one or more IP addresses, and Deny statement to deny access from one  or more IP addresses. In modern Apache versions (2.4+), Require and &#8216;Require not&#8217; statements are preferred over the older Allow and Deny Statements respectively.<\/p>\n\n\n\n<p>These statements can be used within Directory, Files or Location blocks in Apache Config file, or in .htaccess file.<\/p>\n\n\n\n<p>Let us look at both the methods to restrict IP access in Apache &#8211; via configuration file as well as using .htaccess file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Using_Apache_Configuration_File\"><\/span>1. Using Apache Configuration File<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Open Apache configuration file in a text editor.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo vi \/etc\/apache2\/apache2.conf<br>OR<br>Sudo vi \/etc\/httpd\/conf\/httpd.conf<\/pre>\n\n\n\n<p>Add the following statements in Directory, Files or Location blocks to allow\/block access, as per your requirement.<\/p>\n\n\n\n<p>Here is an example to allow access from only one IP address to root directory of your site \/var\/www\/html<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;Directory \"\/var\/www\/html\"&gt;<br>    Require ip 12.34.56.78<br>&lt;\/Directory&gt;<\/pre>\n\n\n\n<p>Here is the command using Allow statement.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;Directory \"\/var\/www\/html\"&gt;<br>    Deny All<br>    Allow 12.34.56.78<br>&lt;\/Directory&gt;<\/pre>\n\n\n\n<p>Here is the command to allow access to all URLs in \/product subfolder.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;Location \"\/product\"><br>    Require ip 12.34.56.78<br>&lt;\/Location><\/pre>\n\n\n\n<p>If you need to provide access from multiple IP addresses, mention separate Require statements for each IP address.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;Directory \"\/var\/www\/html\"&gt;<br>    Require ip 12.34.56.78<br>    Require ip 23.34.45.56<br>&lt;\/Directory&gt;<\/pre>\n\n\n\n<p>If you need to allow access from a group of IP addresses, then you can also use a CIDR subnet mask to specify the range. Here is an example to allow access from 10.0.0.1 to 10.0.255.255.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;Directory \"\/var\/www\/html\"&gt;<br>    Require ip 10.0.0.0\/16<br>&lt;\/Directory&gt;<\/pre>\n\n\n\n<p>Sometimes you may need to allow access from all IPs except one or more IP addresses. In such cases, use Require All statement to give access to all, followed by &#8216;Require not&#8217; statements for IP addresses you want to block. Here is an example to allow access from all IP addresses but block IPs 12.23.34.45 and 20.0.0.0-20.0.255.255.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;Directory \"\/var\/www\/html\"&gt;<br>    Require all granted<br>    Require not ip 12.23.34.45<br>    Require not ip 20.0.255.255\/16<br>&lt;\/Directory&gt;<\/pre>\n\n\n\n<p>When you add the above statements to a Directory block, it will be applicable to all sub directories and files present in it. If you add it to File block, it will be applicable only to the said file. If you use it in Location block, then it will be applicable to all URLs served by that block.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Using_htaccess_file\"><\/span>2. Using .htaccess file<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you do not have access to Apache configuration file, or do not want to modify it, then you can add the above statements to .htaccess file also.<\/p>\n\n\n\n<p>Here is an example to allow only specific IP address.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Require all denied<br>Require ip 12.23.34.45<\/pre>\n\n\n\n<p>On the other hand, here is an example to block only specific IP address.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Require all granted<br>Require not ip 12.23.34.45<\/pre>\n\n\n\n<p>Please note, if you add this code to an .htaccess file, then it will be applied to all files and subdirectories in that directory. Since a website may have multiple .htaccess files, you may place these codes anywhere you want as needed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Points_to_Remember\"><\/span>Points to Remember<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Correct IP Address Group<\/strong> &#8211; While restricting multiple IP addresses using IP subnets, it is important to ensure that you use the proper subnet mask. Otherwise, it will end up blocking a large number of permitted IP addresses.<\/li>\n\n\n\n<li><strong>Order of Directives<\/strong> &#8211; In older Apache servers (&lt;2.4), the order of directives (Allow, Deny, etc.) matters. Apache will parse these directives sequentially one after the other. If you do not follow the correct order, then IP address blocked by one directive may be unblocked by a subsequent directive, and vice versa.<\/li>\n\n\n\n<li><strong>Security<\/strong> &#8211; It is important to remember that IP address may be spoofed. Also, a single IP address may be used by multiple users. So you need to be very careful when you select IP addresses to be blocked.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, we have learnt how to restrict access by IP in Apache. We have covered many common use cases to help you understand when to use which solution. If you find that your website is under attack or being overwhelmed by one or more IPs, then restricting access by IP is your first line of defense. Once you have identified and blocked the malicious IPs, then you can work on fortifying your server as well as application. Depending on your requirement, you can use any of the above steps to control access to Apache server.<\/p>\n\n\n\n<p>Also read:<br><a href=\"https:\/\/ubiq.co\/tech-blog\/upgrade-apache-version-ubuntu\/\">How to Upgrade Apache Version in Ubuntu<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/increase-max-url-length-apache\/\">How to Increase Max URL Length in Apache Server<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/enable-mod_ssl-apache\/\">How to Enable mod_ssl in Apache Server<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you may need to restrict access by IP address in Apache server. Here is how to do it.<\/p>\n","protected":false},"author":1,"featured_media":10096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[249],"class_list":["post-10080","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apache","tag-restrict-access"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Restrict Access by IP in Apache Server - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Sometimes you may need to restrict access by IP address in Apache server. Here is how to do it.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Restrict Access by IP in Apache Server - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Sometimes you may need to restrict access by IP address in Apache server. Here is how to do it.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2025-12-15T04:41:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-12-15T04:41:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/12\/restrict-access-by-ip-apache.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"301\" \/>\n\t<meta property=\"og:image:height\" content=\"200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Restrict Access by IP in Apache Server\",\"datePublished\":\"2025-12-15T04:41:47+00:00\",\"dateModified\":\"2025-12-15T04:41:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/\"},\"wordCount\":952,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/12\/restrict-access-by-ip-apache.jpg?fit=301%2C200&ssl=1\",\"keywords\":[\"restrict access\"],\"articleSection\":[\"Apache\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/\",\"url\":\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/\",\"name\":\"How to Restrict Access by IP in Apache Server - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/12\/restrict-access-by-ip-apache.jpg?fit=301%2C200&ssl=1\",\"datePublished\":\"2025-12-15T04:41:47+00:00\",\"dateModified\":\"2025-12-15T04:41:49+00:00\",\"author\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Sometimes you may need to restrict access by IP address in Apache server. Here is how to do it.\",\"breadcrumb\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/12\/restrict-access-by-ip-apache.jpg?fit=301%2C200&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/12\/restrict-access-by-ip-apache.jpg?fit=301%2C200&ssl=1\",\"width\":301,\"height\":200,\"caption\":\"restrict access by ip in apache\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/ubiq.co\/tech-blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Restrict Access by IP in Apache Server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#website\",\"url\":\"https:\/\/ubiq.co\/tech-blog\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/\"],\"url\":\"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Restrict Access by IP in Apache Server - Ubiq BI","description":"Sometimes you may need to restrict access by IP address in Apache server. Here is how to do it.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/","og_locale":"en_US","og_type":"article","og_title":"How to Restrict Access by IP in Apache Server - Ubiq BI","og_description":"Sometimes you may need to restrict access by IP address in Apache server. Here is how to do it.","og_url":"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2025-12-15T04:41:47+00:00","article_modified_time":"2025-12-15T04:41:49+00:00","og_image":[{"width":301,"height":200,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/12\/restrict-access-by-ip-apache.jpg","type":"image\/jpeg"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Restrict Access by IP in Apache Server","datePublished":"2025-12-15T04:41:47+00:00","dateModified":"2025-12-15T04:41:49+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/"},"wordCount":952,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/12\/restrict-access-by-ip-apache.jpg?fit=301%2C200&ssl=1","keywords":["restrict access"],"articleSection":["Apache"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/","url":"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/","name":"How to Restrict Access by IP in Apache Server - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/12\/restrict-access-by-ip-apache.jpg?fit=301%2C200&ssl=1","datePublished":"2025-12-15T04:41:47+00:00","dateModified":"2025-12-15T04:41:49+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Sometimes you may need to restrict access by IP address in Apache server. Here is how to do it.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/12\/restrict-access-by-ip-apache.jpg?fit=301%2C200&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/12\/restrict-access-by-ip-apache.jpg?fit=301%2C200&ssl=1","width":301,"height":200,"caption":"restrict access by ip in apache"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/apache-restrict-access-by-ip\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Restrict Access by IP in Apache Server"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/12\/restrict-access-by-ip-apache.jpg?fit=301%2C200&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-2CA","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/10080","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=10080"}],"version-history":[{"count":21,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/10080\/revisions"}],"predecessor-version":[{"id":10102,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/10080\/revisions\/10102"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/10096"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=10080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=10080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=10080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}