Skip to content

Instantly share code, notes, and snippets.

@pandanote-info
Created September 28, 2017 22:18
Show Gist options
  • Save pandanote-info/8d6fcfa992c08776e4970d1863432254 to your computer and use it in GitHub Desktop.
Save pandanote-info/8d6fcfa992c08776e4970d1863432254 to your computer and use it in GitHub Desktop.
Apache httpdでIPアドレスやUserAgentでアクセス制御を行うための設定例
# Access is only allowed via local access
# Change this once configured
<Directory /usr/share/a>
AllowOverride Options
<IfModule mod_authz_core.c>
# Apache 2.4
Require all granted
Require local
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
<Directory /usr/share/a/b>
AllowOverride Options
<IfModule mod_authz_core.c>
# Apache 2.4
Require all denied
Require local
Require ip abcd:1234:5678:1::/64
Require ip 192.168.1.1
Require expr %{HTTP_USER_AGENT} =~ /(mobile1|mobile2)/
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment