{"id":84,"date":"2011-12-03T01:25:29","date_gmt":"2011-12-03T01:25:29","guid":{"rendered":"http:\/\/technese.com\/?p=84"},"modified":"2012-05-20T01:25:52","modified_gmt":"2012-05-20T01:25:52","slug":"block-ip-address-using-htaccess-for-apache-or-using-url-access-deny-for-lighttpd","status":"publish","type":"post","link":"https:\/\/technese.com\/index.php\/2011\/12\/03\/block-ip-address-using-htaccess-for-apache-or-using-url-access-deny-for-lighttpd\/","title":{"rendered":"Block IP address using .htaccess for Apache or using url.access-deny for Lighttpd"},"content":{"rendered":"<p>For Apache Web Server, edit the .htaccess per directory:<\/p>\n<p>Allow access from a certain IP address:<\/p>\n<p>In this case, stands for a specific IP address. For example:<\/p>\n<p>order deny,allow<br \/>\ndeny from all<br \/>\nallow from 192.168.1.2<\/p>\n<p>Deny access from a specific IP address:<\/p>\n<p>order allow, deny<br \/>\nallow from all<br \/>\ndeny from 192.168.1.2<\/p>\n<p>For multiple IP addresses:<\/p>\n<p>order deny,allow<br \/>\ndeny from all<br \/>\nallow from 192.168.1.2 192.168.1.3<br \/>\nallow from 192.168.1.4<\/p>\n<p>For Lighttpd web server:<\/p>\n<p>Edit lighttpd.conf<\/p>\n<p>$HTTP[&#8220;remoteip&#8221;] == \u00e2\u20ac\u0153192.168.1.2\u00e2\u20ac\u00b3 {<br \/>\nurl.access-deny = ( \u00e2\u20ac\u0153\u00e2\u20ac\u009d )<br \/>\n}<\/p>\n<p>Do not allow IP address 192.168.1.2, 192.168.1.3 to access our site:<\/p>\n<p>$HTTP[&#8220;remoteip&#8221;] =~ \u00e2\u20ac\u0153192.168.1.2|192.168.1.3\u00e2\u20ac\u00b3 {<br \/>\nurl.access-deny = ( \u00e2\u20ac\u0153\u00e2\u20ac\u009d )<br \/>\n}<\/p>\n<p>or<\/p>\n<p>$HTTP[&#8220;remoteip&#8221;] == \u00e2\u20ac\u0153192.168.1.2|192.168.1.3\u00e2\u20ac\u00b3 {<br \/>\nurl.access-deny = ( \u00e2\u20ac\u0153\u00e2\u20ac\u009d )<br \/>\n}<\/p>\n<p>&nbsp;<\/p>\n<p>Allow ONLY IP addresses, 192.168.1.2, 192.168.1.3 to access,<br \/>\nnote the != which means \u00e2\u20ac\u02dcstring does not match\u00e2\u20ac\u2122 operator basically \u00e2\u20ac\u201c IF remoteip is not<br \/>\n192.168.1.2 or 192.168.1.3, THEN deny:<\/p>\n<p>$HTTP[&#8220;remoteip&#8221;] != \u00e2\u20ac\u0153192.168.1.2|192.168.1.3\u00e2\u20ac\u00b3 {<br \/>\nurl.access-deny = ( \u00e2\u20ac\u0153\u00e2\u20ac\u009d )<br \/>\n}<\/p>\n<p>Reference:<\/p>\n<p><a href=\"http:\/\/www.htpasswdgenerator.com\/apache\/htaccess.html\" target=\"_blank\">http:\/\/www.htpasswdgenerator.com\/apache\/htaccess.html<\/a><br \/>\n<a href=\"http:\/\/www.cyberciti.biz\/tips\/lighttpd-restrict-or-deny-access-by-ip-address.html\" target=\"_blank\">http:\/\/www.cyberciti.biz\/tips\/lighttpd-restrict-or-deny-access-by-ip-address.html<\/a><br \/>\n<a href=\"http:\/\/redmine.lighttpd.net\/wiki\/1\/Docs:Configuration\" target=\"_blank\">http:\/\/redmine.lighttpd.net\/wiki\/1\/Docs:Configuration<\/a><br \/>\n<a href=\"http:\/\/perishablepress.com\/press\/2006\/01\/10\/stupid-htaccess-tricks\" target=\"_blank\">http:\/\/perishablepress.com\/press\/2006\/01\/10\/stupid-htaccess-tricks<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>For Apache Web Server, edit the .htaccess per directory: Allow access from a certain IP address: In this case, stands for a specific IP address. For example: order deny,allow deny from all allow from 192.168.1.2 Deny access from a specific IP address: order allow, deny allow from all deny from 192.168.1.2 For multiple IP addresses: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-84","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/posts\/84","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/comments?post=84"}],"version-history":[{"count":2,"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/posts\/84\/revisions"}],"predecessor-version":[{"id":86,"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/posts\/84\/revisions\/86"}],"wp:attachment":[{"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/media?parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/categories?post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/tags?post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}