Apacheã®ã¢ã¯ã»ã¹å¶å¾¡ãã¡ããã¨ç解ããã
Apacheã®è¨å®ã§
Order deny,allow
ã¨ã
Satisfy any
ã¨ãããªãã ãæå³ãããã人ã®ããã«ãåã¯ãã£ã¨ããã£ã¦ãªãã£ãã
åºæ¬
Apacheã®ã¢ã¯ã»ã¹å¶å¾¡ã«ã¯ã
- ãã¹ãã«ããå¶å¾¡ (Order,Allow,Deny)
- ã¦ã¼ã¶èªè¨¼ã«ããå¶å¾¡ (Auth*, Require)
ã®2éããããã
Satisfyã¯ã2éãããã¢ã¯ã»ã¹å¶å¾¡ã®ä¸¡æ¹ãæºããå¿ è¦ããããã©ããã決å®ãããããã©ã«ãã¯Satisfy allãSatisfy anyãªããã©ã¡ããçæ¹æºããã°ããã
Order
Order deny,allow
ã¯ãå ¨ã¦ã®ãã¹ãããã®ã¢ã¯ã»ã¹ã許å¯ããã
Order allow,deny
ã¯ãå ¨ã¦ã®ãã¹ãããã®ã¢ã¯ã»ã¹ãæå¦ããã
Order deny,allow Allow from 127.0.0.1
ã¯ãå ¨ã¦ã®ãã¹ãããã®ã¢ã¯ã»ã¹ã許å¯ãã¦ãã¾ãããããã¼ã«ã«ããã ã許å¯ããããªãã
Order deny,allow Deny from all Allow from 127.0.0.1
ã¨æ¸ããªããã°ãªããªããéã« allow,deny ãªãã
Order allow,deny Allow from 127.0.0.1
ã§ãã¼ã«ã«ããã®ã¢ã¯ã»ã¹ã ãã許å¯ã§ããã調åã«ä¹ã£ã¦
Order allow,deny Deny from all Allow from 127.0.0.1
ãªã©ã¨ããã¨ãå ¨ã¦ã®ã¢ã¯ã»ã¹ãæå¦ãã¦ãã¾ãã
ã©ãããæå³ï¼
å³ã«ããã¨ããããå¦çããã¦ããã
æ¬ä¼¼ã³ã¼ãã®æ¹ããããããããããããªãã
<Location /> Order deny,allow </Location>
ã¯ã
if (Location.match? /) { access = allow // ããã©ã«ã if (Host.match? none) { // denyæ¡ä»¶(ãªã) access = deny if (Host.match? none) { // allowæ¡ä»¶(ãªã) access = allow } } }
ã¨ããå¦çããã¦ãããããã©ã«ãã®åå¨ã«æ³¨ç®ãOrder deny,allowã®å ´åãã¾ãããã©ã«ãã§è¨±å¯ãããã次ã«Deny fromã®æ¡ä»¶ã«åãã調ã¹ãããåè´ãããæ絶ã«å¤ãããããã«Allow fromã«åè´ããã¨è¨±å¯ã«æ»ãã
Order allow,denyã®å ´åã¯ãéã«æ絶ãããã©ã«ãã«ãªãã
<Location /> Order allow,deny Allow from all Deny from spam.example.com </Location>
ã¯ã
if (Location.match? /) { access = deny // ããã©ã«ã if (Host.match? all) { // allowæ¡ä»¶ access = allow if (Host.match? spam.exaple.com) { // denyæ¡ä»¶ access = deny } } }
ã¨ããå¦çã«ãªããspam.example.com 以å¤ã®ãã¹ãã許å¯ãããã
- Order (allow,)deny,allow
- Order (deny,)allow,deny
ã®ããã«å é ã«çç¥ãããã¨èããã¨ãããããããããè¦ãããã®ã¯ã
Order deny,allow Deny from all Allow from xxx
ã¨ãããã¿ã¼ã³ãããã¯ãAllowã«ããããããã¹ãã ãã許å¯ãã¾ããã¨ããæå³ã
Order allow,deny Allow from xxx
ã¨åãã ããå ¨ã¦ãæ絶ãã(Deny from all)ã¨æ示çã«æ¸ããæ¹ãããããããã
ãªããifæãå ¥ãåã«ãªã£ã¦ããã¨èããå¿ è¦ã¯ãªããOrder deny,allow ã¯ã
if (Location.match? /) { access = allow if (Host.match? none) access = deny if (Host.match? none) access = allow }
ã¨ããæ¬ä¼¼ã³ã¼ãã®æ¹ãé©å½ãããããªãããã ãèªåã¯å ¥ãåã«ãªã£ã¦ããæ¹ãç解ããããã£ããdenyã§ãªããªãä¸ã®å¤å®ã¯ä¸è¦ã ãã
ãã¼ã¸
ããã¾ã§æããä¾ã«ã¯ <Location /> ã1ã¤ããåºã¦ããªãã£ããè¤æ°ã® Location ã»ã¯ã·ã§ã³ãããã¨ã©ããªããã
ããã¥ã¢ã«ã§ã¯ã
ã§ãã¼ã¸ãå²ãã¦è§£èª¬ãã¦ããã
- Directory以å¤ã¯ãè¨å®ãã¡ã¤ã«ã«ç¾ããé çªã«å¦çãããã
- Directoryã¯çãæ¹ããé·ãæ¹ã«ä¸¦ã¹æ¿ãã¦ããå¦çãããã
- è¤æ°ã®Directoryãåããã£ã¬ã¯ããªã«é©ç¨ãããå ´åã¯ãè¨å®ãã¡ã¤ã«ã®é ã«å¦çãããã
ã¨ãããã¨ãªã®ã ãããå¦çããããã®å 容ãããããªãã
次ã®ã¹ã¯ãªãããæ¸ãã¦ãè¨å®ãå¤ããªããå®é¨ãããããã¥ã¡ã³ãã«ã¼ãã« index.html 㨠1 ã¨ãããã¡ã¤ã«ãç½®ãã¦ããã
#! /bin/sh /opt/local/apache2/bin/apachectl restart echo / curl -s -I http://default.local/ | head -n1 echo /1 curl -s -I http://default.local/1 | head -n1
ã¾ããLocationã®ä¸ã«ä½ãæ¸ããªãã£ãå ´åã
<Location /> Order allow,deny Allow from all Deny from all </Location> <Location /1> </Location>
ãã㯠/ ã /1 ãæ絶ããããä½ãæ¸ããªãå ´åãããã©ã«ãã§ä¸æ¸ãããããã¯ããªãã
/ HTTP/1.1 403 Forbidden /1 HTTP/1.1 403 Forbidden
次㫠Order ã ããçç¥ããã¨ã©ããªããã
<Location /> Order allow,deny Allow from all Deny from all </Location> <Location /1> Allow from all Deny from all </Location>
ãã㯠/ ã¯æ絶ããã/1 ã¯è¨±å¯ãããã
/ HTTP/1.1 403 Forbidden /1 HTTP/1.1 200 OK
/ ã /1 ãåãããã« Allow from all,Deny from all ãã¦ãããã¨ã«æ³¨æã/1ã ãã許å¯ãããã®ã¯ãããã©ã«ãã® Order deny,allow ãé©ç¨ããããããæ¬ä¼¼ã³ã¼ãã ã¨ã
if (Location.match? /) { access = deny if (Host.match? all) { access = allow if (Host.match? all) { access = deny // å ¨ã¦ã®ã¢ã¯ã»ã¹ãã¾ãæ絶ãããã } } } if (Location.match? /1) { access = allow // ããã©ã«ãã® Order deny,allow if (Host.match? all) { access = deny if (Host.match? all) { access = allow // /1ã¯ãããé©ç¨ãããã } } }
ã¨ãªããOrder,Allow,Deny ã¯3ã¤ã§1ã»ãã(mod_authz_host)ã§ãã©ãã1ã¤ãæ¸ãã¨ããã©ã«ããæå¹ã«ãªãããã ã
Location ã¯è¨å®ãã¡ã¤ã«å ã®é åºã«å½±é¿ãåãããä¸ã®è¨å®ã®é åºã ããå ¥ãæ¿ããã¨çµæãå¤ããã
<Location /1> Allow from all Deny from all </Location> <Location /> Order allow,deny Allow from all Deny from all </Location>
/ HTTP/1.1 403 Forbidden /1 HTTP/1.1 403 Forbidden
ããã¯ifæãå ¥ãæ¿ããããã
if (Location.match? /1) { access = allow // Order deny,allow if (Host.match? all) { access = deny if (Host.match? all) { access = allow // /1ã許å¯ããããã } } } if (Location.match? /) { access = deny if (Host.match? all) { access = allow if (Host.match? all) { access = deny // çµå±å ¨é¨æå¦ããã¦ãã¾ãã } } }
Satisfy Any
ã¦ã¼ã¶èªè¨¼ã¨ä½µç¨ããã¨ã©ããªããã
<Location /> Order deny,allow Deny from all Allow from 127.0.0.1 AuthType Basic AuthName "Staff Only" AuthUserFile /path/to/pass Require valid-user Satisfy any </Location> <Location /1> Order deny,allow Deny from all </Location>
/ HTTP/1.1 200 OK /1 HTTP/1.1 401 Authorization Required
Satisfy any ã®å¹æã§ããã¼ã«ã«ããèªè¨¼ãªã㧠/ ã«ã¢ã¯ã»ã¹ã§ãããããã¾ã§ã¯è¯ãã /1 ã®æ¹ãåé¡ãæ示çã«ã¢ã¯ã»ã¹ãç¦æ¢ãã¦ããã®ã«ããªããèªè¨¼ãæ±ãããããèªè¨¼ãéãã¨ã¢ã¯ã»ã¹ã§ãã¦ãã¾ãã
ãã®æåã¯ã次ã®ãããªæ¬ä¼¼ã³ã¼ããèããã¨ãç解ã§ããã
// ããã©ã«ãã¯ä½ãå¶éãããªãã access = allow; hostAccess = allow; authAccess = allow; // /ã®ãã¹ãå¶éã if (Location.match? /) { hostAccess = allow; if (Host.match? all) { hostAccess = deny; if (Host.match? 127.0.0.1) { hostAccess = allow; } } } // Basicèªè¨¼ã if (Location.match? /) { authAccess = deny; if (User.match? valid-user) { authAccess = allow; } } // /1ã®ãã¹ãå¶éã if (Location.match? /1) { hostAccess = allow; if (Host.match? all) { hostAccess = deny; if (Host.match? none) { hostAccess = allow; } } } // æå¾ã«Satisfy anyã®å¤å®ãè¡ãã if (Location.match? /) { access = deny; if (hostAccess || authAccess) { access = allow; } }
/1 㯠Location / ã«åè´ããã®ã§ãBasicèªè¨¼ãé©ç¨ãããããã« Satisfy any ãé©ç¨ãããã
ã¨ããããã§ã/1 ã«ã¯ Satisfy all ãæ¸ãã®ãæ£è§£ã
<Location /> Order deny,allow Deny from all Allow from 127.0.0.1 AuthType Basic AuthName "Staff Only" AuthUserFile /path/to/pass Require valid-user Satisfy any </Location> <Location /1> Order deny,allow Deny from all Satisfy all </Location>
ããã§ããã¹ãã®æ¡ä»¶ãå¿ é ã«ãªãã/1 ã¸ã®ã¢ã¯ã»ã¹ãå ¨ã¦æå¦ãããã
/ HTTP/1.1 200 OK /1 HTTP/1.1 403 Forbidden
Directory
åå°½ãã¾ãããçãã®ããé·ãã®ã®é ã«ä¸¦ã¹æ¿ãã¦ããå¦çãããã¨ã®ãã¨ã
念ã®ããæ¸ãã¨ä¸ã®ãããªä¾ã§ã¯ Location ã§ã¯ãªã Directory/Files ã使ãã¹ãã
ã¾ã¨ã
ãããªããããã¦ãã¦ãæ¬å½ã¯ã©ãã§ãããã¨æããApache 3.0ã§ã¯ããã£ãããDSL(VCL)ã§æ¸ããããã«ããæ§æ³ããããããã®ã§ããã°ã£ã¦ã»ããã
- 【レポート】高速化プログラミングの参照実装としても活用される「Varnish」 (1) OSの機能をフル活用してHTTPサーバの動きを高速化するHTTPアクセラレータ | エンタープライズ | マイナビニュース (2007å¹´ã ãã©)
å¯èªæ§ã¨è¤éãã®ä¸¡ç«ã«ã¯ DSL ãåãã¦ãããè¨å®ã®ä¸ã«å¶å¾¡æ§é ãå«ã¾ãããããªå ´åã¯ç¹ã« DSL ããããèªåèªèº«ã説æããªãããã£ãã©ãªã¯ç¬åã§éªæªã§ãã