{"id":55,"date":"2011-01-13T20:28:46","date_gmt":"2011-01-14T00:28:46","guid":{"rendered":"http:\/\/www.lektrikpuke.com\/blog\/?p=55"},"modified":"2012-06-24T10:12:10","modified_gmt":"2012-06-24T14:12:10","slug":"restricting-access-to-one-folder-on-webserver","status":"publish","type":"post","link":"https:\/\/lektrikpuke.com\/blog\/2011\/01\/13\/restricting-access-to-one-folder-on-webserver\/","title":{"rendered":"Restricting Access To One Folder On Webserver"},"content":{"rendered":"<p>I have Apache webserver running on my personal computer so I can do testing locally (before embarrassing myself on the internet).\u00a0 I am also networked locally to other computers in my home.\u00a0 For reasons I won&#8217;t go into, I want to allow the other computers on my intranet access to one of my folders (but not all) on my webserver.\u00a0 Maybe you have a test folder that you don&#8217;t want people at work to see (think &#8216;your boss might freak to see unfinished work&#8217;)?\u00a0 This&#8217;ll work perfectly for that.<\/p>\n<p>I thought at first that this was a job for .htaccess (and maybe that is one way to do it), but that&#8217;s not what I ended up modifying.\u00a0 After a little research I discovered this could be done very easily by modifying Apache&#8217;s httpd.conf file.<\/p>\n<p>If you&#8217;re looking to do something similar, try adding the following to the end of your Apache httpd.conf file (NOTE:\u00a0 Do not add my comments as denoted here by #):<\/p>\n<p>&lt;LocationMatch &quot;\/&quot;&gt;<br \/>\nOrder Deny,Allow<br \/>\nDeny from all<br \/>\nAllow from 127.0.0.1<br \/>\n&lt;\/LocationMatch&gt;<\/p>\n<p># First thing we do is restrict everyone from our webserver except our own computer<br \/>\n# What folder do you want this rule to apply to?\u00a0 We want this rule to apply to the root folder &#8211; denoted by \/<br \/>\n# Who do we want this rule to apply to? We want this to apply to everyone &#8211; Deny from all<br \/>\n# We still want to have access from our own computer, right? Yup &#8211; Allow from 127.0.0.1 &#8211; that&#8217;s your computer<\/p>\n<p>&lt;LocationMatch &quot;\/folder_name_that_you_want_to_allow_access_to\/&quot;&gt;<br \/>\nOrder Deny,Allow<br \/>\nDeny from all<br \/>\nAllow from 127.0.0.1<br \/>\nAllow from 192.168.0<br \/>\n&lt;\/LocationMatch&gt;<\/p>\n<p># Now we list the folder we want this rule to apply to, deny access to all (always done first for security), then allow our computer access and other computers on our intranet<br \/>\n# What folder do you want this rule to apply to? We want this rule to apply to a specific folder &#8211; put the name of that folder in place of folder_name_that_you_want_to_allow_access_to<br \/>\n# Who do we want this rule to apply to? We want this to apply to everyone &#8211; Deny from all<br \/>\n# We still want to have access from our own computer, right? Yup &#8211; Allow from 127.0.0.1 &#8211; that&#8217;s your computer<br \/>\n# What other computers do we want to have access? On my intranet we&#8217;re using 192.168.0.X range (your intranet may use a different range), so we allow from 192.168.0 (it&#8217;s not a typo leaving the last period and number off here)<\/p>\n<p>That&#8217;s all there is to it.\u00a0 Of course, I&#8217;m assuming you have your webserver set up correctly, have pages that display properly, and the correct firewall settings.\u00a0 Note:\u00a0 You should check to see if your pages are displaying properly on your intranet before modifying your httpd.conf file.\u00a0 Also, backing up the file before modifying it is a really smart thing to do.<\/p>\n<p>Oh, almost forgot, if you serve pages to the internet, you need to add your proxy (ip address of your internet gateway) to your allows where appropriate (if different from your intranet ip range).<\/p>\n<p>Note:  If you copy the examples above, be sure the quotes are plain quotes (they should be) or the filter may not work.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have Apache webserver running on my personal computer so I can do testing locally (before embarrassing myself on the internet).\u00a0 I am also networked locally to other computers in my home.\u00a0 For reasons I won&#8217;t go into, I want &hellip; <a href=\"https:\/\/lektrikpuke.com\/blog\/2011\/01\/13\/restricting-access-to-one-folder-on-webserver\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[72],"tags":[22,79,80,81,83,84,82],"class_list":["post-55","post","type-post","status-publish","format-standard","hentry","category-computer-stuff","tag-htaccess","tag-apache","tag-http-conf","tag-intranet","tag-lan","tag-local-area-network","tag-restrict-access"],"_links":{"self":[{"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/posts\/55","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/comments?post=55"}],"version-history":[{"count":6,"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/posts\/55\/revisions"}],"predecessor-version":[{"id":150,"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/posts\/55\/revisions\/150"}],"wp:attachment":[{"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/media?parent=55"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/categories?post=55"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lektrikpuke.com\/blog\/wp-json\/wp\/v2\/tags?post=55"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}