{"id":110,"date":"2012-02-27T11:09:43","date_gmt":"2012-02-27T10:09:43","guid":{"rendered":"http:\/\/svalgaard.net\/jens\/blog\/?p=110"},"modified":"2012-02-27T11:11:25","modified_gmt":"2012-02-27T10:11:25","slug":"apache2-require-password-for-remote-users-and-not-local","status":"publish","type":"post","link":"https:\/\/svalgaard.net\/jens\/blog\/2012\/02\/apache2-require-password-for-remote-users-and-not-local\/","title":{"rendered":"Apache2: Require password for remote users (and not local)"},"content":{"rendered":"<p>Sometimes it is nice to require password for a site, but only if they are not from a particular ip-number, <!--more-->i.e., users connected to your local Wireless LAN should be able to connect directly to your home server, while remote users needs a password.<\/p>\n<p>Add the following snippet in the right location in one of your \/etc\/apache2\/sites-enabled\/ files:<\/p>\n<p><code>&lt;Location \/&gt;<br \/>\n&nbsp;&nbsp;Order deny,allow<br \/>\n&nbsp;&nbsp;Deny from all<br \/>\n&nbsp;&nbsp;# allow anybody at home to access this site<br \/>\n&nbsp;&nbsp;Allow from 127.0.0.0\/8 ::1\/128 <strong>172.16.0.0\/16<\/strong><br \/>\n&nbsp;&nbsp;# also allow if ther user login<br \/>\n&nbsp;&nbsp;AuthType Basic<br \/>\n&nbsp;&nbsp;AuthUserFile <strong>\/home\/www\/.htpasswd\/mw<\/strong><br \/>\n&nbsp;&nbsp;AuthName \"beatrix\"<br \/>\n&nbsp;&nbsp;Require valid-user<br \/>\n&nbsp;&nbsp;Satisfy any<br \/>\n&lt;\/Location&gt;<\/code><\/p>\n<p>Of course replacing the parts in bold with your own details. A password file can be created using the command htpasswd.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes it is nice to require password for a site, but only if they are not from a particular ip-number,<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-110","post","type-post","status-publish","format-standard","hentry","category-stuff"],"_links":{"self":[{"href":"https:\/\/svalgaard.net\/jens\/blog\/wp-json\/wp\/v2\/posts\/110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/svalgaard.net\/jens\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/svalgaard.net\/jens\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/svalgaard.net\/jens\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/svalgaard.net\/jens\/blog\/wp-json\/wp\/v2\/comments?post=110"}],"version-history":[{"count":3,"href":"https:\/\/svalgaard.net\/jens\/blog\/wp-json\/wp\/v2\/posts\/110\/revisions"}],"predecessor-version":[{"id":113,"href":"https:\/\/svalgaard.net\/jens\/blog\/wp-json\/wp\/v2\/posts\/110\/revisions\/113"}],"wp:attachment":[{"href":"https:\/\/svalgaard.net\/jens\/blog\/wp-json\/wp\/v2\/media?parent=110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/svalgaard.net\/jens\/blog\/wp-json\/wp\/v2\/categories?post=110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/svalgaard.net\/jens\/blog\/wp-json\/wp\/v2\/tags?post=110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}