{"id":2109,"date":"2021-02-26T14:58:00","date_gmt":"2021-02-26T13:58:00","guid":{"rendered":"https:\/\/hoover.gplrank.de\/?p=2109"},"modified":"2021-02-26T15:05:05","modified_gmt":"2021-02-26T14:05:05","slug":"apache2-basic-auth-ip-based-authentication","status":"publish","type":"post","link":"https:\/\/hoover.gplrank.de\/?p=2109","title":{"rendered":"apache2 basic auth \/ ip based authentication"},"content":{"rendered":"\n<p>As I keep forgetting how this works, here&#8217;s an example config that will require basic auth for the &#8220;\/&#8221; URI while permitting basic-authless access to &#8220;\/test&#8221; for IPs listed in the <code>Allow from<\/code> statement (other source IPs will still be able to access stuff in &#8220;\/test&#8221; if proper basic authentication info is provided with the request): <\/p>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><code><em>#<\/em> httpd.conf&nbsp;<\/code><\/p><p><code># basic auth f\u00fcr \"\/\" und \"\/test\" except for IPs listed in the  \"Allow from...\" Statement&nbsp;<\/code><\/p><p><code>&lt;Location \/&gt;&nbsp;<\/code><\/p><p><code>&nbsp;&nbsp; AuthType Basic&nbsp;<\/code><\/p><p><code>&nbsp;&nbsp; AuthUserFile \/etc\/httpd\/conf\/htpasswd&nbsp;<\/code><\/p><p><code>&nbsp;&nbsp; AuthName \"Authorized Users Only\"&nbsp;<\/code><\/p><p><code>&nbsp;&nbsp; require valid-user&nbsp;<\/code><\/p><p><code>&lt;\/Location&gt;&nbsp;<\/code><\/p><p><code>&lt;LocationMatch \/test\/*&gt;&nbsp;<\/code><\/p><p><code>&nbsp;&nbsp; Order Deny,Allow&nbsp;<\/code><\/p><p><code>&nbsp;&nbsp; Satisfy any&nbsp;<\/code><\/p><p><code>&nbsp;&nbsp; Deny from all&nbsp;<\/code><\/p><p><code>&nbsp;&nbsp; Require valid-user&nbsp;<\/code><\/p><p><code>&nbsp;&nbsp; Allow from AAA.XXX.YYY.ZZZ&nbsp;<\/code><\/p><p><code>&lt;\/LocationMatch&gt;&nbsp;<\/code><\/p><\/blockquote>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>As I keep forgetting how this works, here&#8217;s an example config that will require basic auth for the &#8220;\/&#8221; URI while permitting basic-authless access to &#8220;\/test&#8221; for IPs listed in the Allow from statement (other source IPs will still be able to access stuff in &#8220;\/test&#8221; if proper basic authentication info is provided with the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-2109","post","type-post","status-publish","format-standard","hentry","category-it"],"_links":{"self":[{"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=\/wp\/v2\/posts\/2109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2109"}],"version-history":[{"count":5,"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=\/wp\/v2\/posts\/2109\/revisions"}],"predecessor-version":[{"id":2114,"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=\/wp\/v2\/posts\/2109\/revisions\/2114"}],"wp:attachment":[{"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hoover.gplrank.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}