- »óȲ¼³¸í:
-
ÃÖ±Ù
foo.html
À»bar.html
·Î º¯°æÇÏ°í ¿ªÈ£È¯¼ºÀ» À§ÇØ ÀÌÀü URLÀ» °è¼Ó Á¦°øÇÏ°í ½Í´Ù°í °¡Á¤ÇÏÀÚ. »ç¿ëÀÚ´Â ÀÌÀü URLÀÌ º¯°æµÇ¾ú´Ù´Â »ç½ÇÀ» ´«Ä¡Ã¤Áö ¸øÇÑ´Ù. - ÇØ°áÃ¥:
-
´ÙÀ½ ±ÔÄ¢À¸·Î ÀÌÀü URLÀ» ³»ºÎÀûÀ¸·Î »õ·Î¿î URL·Î ÀçÀÛ¼ºÇÑ´Ù:
RewriteEngine on RewriteBase /~quux/ RewriteRule ^foo\.html$ bar.html
- »óȲ¼³¸í:
-
´Ù½Ã
foo.html
À»bar.html
·Î º¯°æÇÏ°í ¿ªÈ£È¯¼ºÀ» À§ÇØ ÀÌÀü URLÀ» °è¼Ó Á¦°øÇÏ°í ½Í´Ù°í °¡Á¤ÇÏÀÚ. ±×·¯³ª ÀÌÁ¦´Â ÀÌÀü URLÀ» »ç¿ëÇÏ¸é »ç¿ëÀÚ¿¡°Ô »õ·Î¿î URLÀ» ÈùÆ®·Î ¾Ë·ÁÁØ´Ù. Áï, ºê¶ó¿ìÀú ÁÖ¼ÒâÀÌ º¯ÇÑ´Ù. - ÇØ°áÃ¥:
-
»õ·Î¿î URL·Î HTTP ¸®´ÙÀÌ·º¼ÇÇÏ´Ù. ±×·¯¸é ºê¶ó¿ìÀú°¡ »õ·Î¿î URL¸¦ º¸ÀÌ°í º¯°æ»ç½ÇÀ» »ç¿ëÀÚ°¡ ¾Ë°ÔµÈ´Ù:
RewriteEngine on RewriteBase /~quux/ RewriteRule ^foo\.html$ bar.html [R]
- »óȲ¼³¸í:
-
ÃÖ¼ÒÇÑ Áß¿äÇÑ ÃÖ»óÀ§ ÆäÀÌÁö´Â ºê¶ó¿ìÀú¿¡ ÃÖÀûÈµÈ ³»¿ëÀ¸·Î ¼ºñ½ºÇؾßÇÒ °æ¿ì°¡ ÀÖ´Ù. Áï, ÃֽŠNetscape ºê¶ó¿ìÀú¿¡°Ô´Â ÃÖ»óÀÇ ¹öÀüÀ», Lynx ºê¶ó¿ìÀú¿¡°Ô´Â ÃÖÀú ¹öÀüÀ», ³ª¸ÓÁö ºê¶ó¿ìÀú¿¡´Â Æò±ÕÀûÀÎ ¹öÀüÀ» Á¦°øÇÑ´Ù.
- ÇØ°áÃ¥:
-
ºê¶ó¿ìÀú°¡ ³»¿ëÇù»óÀ» À§ÇØ ÀÚ½ÅÀÇ Á¾·ù¿¡ ´ëÇÑ Á¤º¸¸¦ Á¦°øÇÏÁö ¾Ê±â¶§¹®¿¡ ³»¿ëÇù»óÀ» »ç¿ëÇÒ ¼ö ¾ø´Ù. ´ë½Å HTTP "User-Agent" Çì´õ¸¦ »ç¿ëÇÑ´Ù. ´ÙÀ½ ±ÔÄ¢Àº HTTP "User-Agent" Çì´õ°¡ "Mozilla/3"À¸·Î ½ÃÀÛÇϸé
foo.html
ÆäÀÌÁö¸¦foo.NS.html
·Î ÀçÀÛ¼ºÇÏ°í ÀçÀÛ¼ºÀ» Áß´ÜÇÑ´Ù. ºê¶ó¿ìÀú°¡ "Lynx"³ª "Mozilla" ¹öÀü 1 ȤÀº 2¶ó¸é URLÀºfoo.20.html
ÀÌ µÈ´Ù. ³ª¸ÓÁö ºê¶ó¿ìÀú´Âfoo.32.html
ÆäÀÌÁö¸¦ ¹Þ´Â´Ù. ¾Æ·¡ ±ÔÄ¢ÀÌ ÀÌ ÀÛ¾÷À» ÇÑ´Ù:RewriteCond %{HTTP_USER_AGENT} ^Mozilla/3.* RewriteRule ^foo\.html$ foo.NS.html [L] RewriteCond %{HTTP_USER_AGENT} ^Lynx/.* [OR] RewriteCond %{HTTP_USER_AGENT} ^Mozilla/[12].* RewriteRule ^foo\.html$ foo.20.html [L] RewriteRule ^foo\.html$ foo.32.html [L]
- »óȲ¼³¸í:
-
¿ÜºÎ È£½ºÆ®¿¡ ¿ì¸® »çÀÌÆ®·Î °¡Á®¿À°í ½ÍÀº ÁÁÀº À¥ÆäÀÌÁö°¡ ÀÖ´Ù°í °¡Á¤ÇÏÀÚ. FTP ¼¹öÀÇ °æ¿ì Á÷Á¢ ¿ÜºÎ ÀÚ·áÀÇ Ãֽź¹»çº»À» À¯ÁöÇÏ´Â
mirror
ÇÁ·Î±×·¥À» »ç¿ëÇÒ ¼ö ÀÖ°í, À¥¼¹ö¶ó¸é HTTP·Î ºñ½ÁÇÑ ÀÛ¾÷À» ÇÏ´Âwebcopy
ÇÁ·Î±×·¥À» »ç¿ëÇÒ ¼ö ÀÖ´Ù. ±×·¯³ª µÎ ¹æ¹ý ¸ðµÎ ´ÜÁ¡ÀÌ ÀÖ´Ù: º¹»çº»Àº °¡²û¾¿ ÇÁ·Î±×·¥À» ½ÇÇàÇØÁÙ ¶§¸¸ ÃÖ½ÅÆÇÀ¸·Î À¯ÁöµÈ´Ù. Á÷Á¢ ±¸¼ºÇؾßÇÏ´Â Á¤ÀûÀÎ ¹Ì·¯°¡ ¾Æ´Ï¶ó¸é ÁÁ°Ú´Ù. ´ë½Å (¿ÜºÎ È£½ºÆ®¿¡¼ ÀÚ·á°¡ °»½ÅµÇ¸é) ÇÊ¿äÇÒ¶§ ÀÚµ¿À¸·Î ÀڷḦ °»½ÅÇÏ´Â µ¿Àû ¹Ì·¯°¡ ÇÊ¿äÇÏ´Ù. - ÇØ°áÃ¥:
-
À̸¦ À§ÇØ Proxy Throughput ±â´ÉÀ» (Ç÷¡±×
[P]
) »ç¿ëÇÏ¿© ¿ÜºÎ À¥ÆäÀÌÁö ȤÀº ¿ÜºÎ À¥°ø°£ Àüü¸¦ ¿ì¸® À̸§°ø°£À¸·Î ´ëÀÀÇÑ´Ù:RewriteEngine on RewriteBase /~quux/ RewriteRule ^hotsheet/(.*)$ http://www.tstimpreso.com/hotsheet/$1 [P]
RewriteEngine on RewriteBase /~quux/ RewriteRule ^usa-news\.html$ http://www.quux-corp.com/news/index.html [P]
- »óȲ¼³¸í:
- ...
- ÇØ°áÃ¥:
-
RewriteEngine on RewriteCond /mirror/of/remotesite/$1 -U RewriteRule ^http://www\.remotesite\.com/(.*)$ /mirror/of/remotesite/$1
- »óȲ¼³¸í:
-
½ÇÁ¦ ÀڷḦ ¹æȺ®ÀÌ º¸È£ÇÏ´Â (³»ºÎ) ÀÎÆ®¶ó³Ý À¥¼¹ö¿¡ (
www2.quux-corp.dom
) ÀúÀåÇϸé¼, ±â¾÷ÀÇ (¿ÜºÎ) ÀÎÅÍ³Ý À¥¼¹ö¸¦ (www.quux-corp.dom
) ½ÇÇàÇÏ´Â °Íó·³ º¸ÀÌ°Ô ÇÑ´Ù. ¿ÜºÎ À¥¼¹ö´Â ¿äûÇÑ ÀڷḦ ³»ºÎ À¥¼¹ö¿¡¼ °¡Á®¿Â´Ù. - ÇØ°áÃ¥:
-
¸ÕÀú ¹æȺ®ÀÌ ³»ºÎ À¥¼¹ö¸¦ º¸È£ÇÏ°í ¿ÜºÎ À¥¼¹ö¸¸ÀÌ ³»ºÎ À¥¼¹ö¿¡¼ ÀڷḦ ¾òÀ» ¼ö ÀÖ°Ô ÇÑ´Ù. ´ÙÀ½°ú °°ÀÌ ÆÐŶÇÊÅ͸µ ¹æȺ®À» ¼³Á¤ÇÑ´Ù:
ALLOW Host www.quux-corp.dom Port >1024 --> Host www2.quux-corp.dom Port 80 DENY Host * Port * --> Host www2.quux-corp.dom Port 80
½ÇÁ¦ ¼³Á¤¹®¹ý¿¡ ¾Ë¸Â°Ô °íÃĶó. ¾ø´Â ÀڷḦ ³»ºÎÀûÀ¸·Î proxy throughput ±â´ÉÀ» ÅëÇØ ¿äûÇÏ´Â
mod_rewrite ±ÔÄ¢À» ÀÛ¼ºÇÑ´Ù:RewriteRule ^/~([^/]+)/?(.*) /home/$1/.www/$2 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/home/([^/]+)/.www/?(.*) http://www2.quux-corp.dom/~$1/pub/$2 [P]
- »óȲ¼³¸í:
-
www.foo.com
ÀÇ Åë½Å·®À»www[0-5].foo.com
(ÃÑ ¼¹ö 6´ë)À¸·Î ºÐ»êÇÏ°í ½Í´Ù. ¾î¶»°Ô Çϴ°¡? - ÇØ°áÃ¥:
-
¸Å¿ì ´Ù¾çÇÑ ¹æ¹ýÀ¸·Î ÀÌ ¹®Á¦¸¦ ÇØ°áÇÒ ¼ö ÀÖ´Ù. ¸ÕÀú DNS¸¦ »ç¿ëÇÑ Àß ¾Ë·ÁÁø ¹æ¹ýÀ» ¼³¸íÇÏ°í,
mod_rewrite ¸¦ »ç¿ëÇÏ´Â °æ¿ì¸¦ »ìÆ캸ÀÚ:-
DNS Round-Robin
°¡Àå °£´ÜÇÑ ·Îµå¹ë·±½Ì ¹æ¹ýÀº
BIND
ÀÇ DNS round-robin ¹æ½ÄÀ» »ç¿ëÇÏ´Â °ÍÀÌ´Ù. ´ÙÀ½°ú °°ÀÌ DNS A(address) ·¹Äڵ忡www[0-9].foo.com
À» ¼³Á¤ÇÑ´Ù.www0 IN A 1.2.3.1 www1 IN A 1.2.3.2 www2 IN A 1.2.3.3 www3 IN A 1.2.3.4 www4 IN A 1.2.3.5 www5 IN A 1.2.3.6
±×¸®°í ´ÙÀ½ Ç׸ñÀ» Ãß°¡ÇÑ´Ù:
www IN CNAME www0.foo.com. IN CNAME www1.foo.com. IN CNAME www2.foo.com. IN CNAME www3.foo.com. IN CNAME www4.foo.com. IN CNAME www5.foo.com. IN CNAME www6.foo.com.
À߸øµÈ °Íó·³ º¸ÀÌÁö¸¸, ½ÇÁ¦·Î
BIND
ÀÇ ÀǵµµÈ ±â´ÉÀÌ´Ù. ÀÌÁ¦www.foo.com
À» ãÀ¸¸é,BIND
´Â ¸Å¹ø ¼ø¼¸¦ Á¶±Ý¾¿ ¹Ù²ã°¡¸çwww0-www6
À» ¹ÝȯÇÑ´Ù. ±×·¡¼ Ŭ¶óÀ̾ðÆ®µéÀ» ¿©·¯ ¼¹ö·Î ºÐ»êÇÑ´Ù. ±×·¯³ª DNS °Ë»ö °á°ú°¡ ³×Æ®¿÷ÀÇ ´Ù¸¥ ³×ÀÓ¼¹ö¿¡ ij½¬µÇ¿©www.foo.com
À» ãÀº °á°ú°¡ ƯÁ¤wwwN.foo.com
À̸é Ŭ¶óÀ̾ðÆ®ÀÇ ´ÙÀ½ ¿äûµéµµ °°ÀºwwwN.foo.com
À¸·Î º¸³»Áö±â¶§¹®¿¡ ¿Ïº®ÇÑ ·Îµå¹ë·±½Ì ±â¹ýÀÌ ¾Æ´ÔÀ» ÁÖÀÇÇ϶ó. ±×·¯³ª Å©°Ô º¸¸é ¿äûÀÌ ¿©·¯ À¥¼¹ö¿¡ ºÐ»êµÇ¹Ç·Î È¿°ú°¡ ÁÁ´Ù. -
DNS ·Îµå¹ë·±½Ì
http://www.stanford.edu/~schemers/docs/lbnamed/lbnamed.html¿¡ ÀÖ´Â
lbnamed
ÇÁ·Î±×·¥À» »ç¿ëÇÏ¿© Á¤±³ÇÑ DNS±â¹Ý ·Îµå¹ë·±½ÌÀ» ÇÒ ¼ö ÀÖ´Ù. DNS°¡ ½ÇÁ¦ ·Îµå¹ë·±½ÌÀ» Çϵµ·Ï ¸¸µå´Â ¿©·¯ µµ±¸¿Í Perl 5 ÇÁ·Î±×·¥ÀÌ´Ù. -
Proxy Throughput Round-Robin
ÀÌ ¹æ¹ýÀº
mod_rewrite ¿Í proxy throughput ±â´ÉÀ» »ç¿ëÇÑ´Ù. ¸ÕÀú DNS¿¡ ´ÙÀ½ Ç׸ñÀ» »ç¿ëÇÏ¿©www0.foo.com
ÀÌ ½ÇÁ¦www.foo.com
À» Àü´ãÇÏ°Ô ÇÑ´Ùwww IN CNAME www0.foo.com.
±×¸®°í
www0.foo.com
À» ÇÁ·Ï½ÃÀü¿ë ¼¹ö·Î º¯°æÇÑ´Ù. Áï, URLÀ» ¹ÞÀ¸¸é ¼¹ö´Â ³»ºÎ ÇÁ·Ï½Ã¸¦ ÅëÇØ ´Ù¸¥ 5´ë ¼¹öÁß (www1-www5
) ÇÑ´ë·Î º¸³»±â¸¸ ÇÑ´Ù. À̸¦ À§ÇØ ¸ÕÀú ¸ðµç URLÀ» ·Îµå¹ë·±½Ì ½ºÅ©¸³Æ®lb.pl
·Î º¸³»´Â ±ÔÄ¢À» ¸¸µç´Ù.RewriteEngine on RewriteMap lb prg:/path/to/lb.pl RewriteRule ^/(.+)$ ${lb:$1} [P,L]
lb.pl
À» ÀÛ¼ºÇÑ´Ù:#!/path/to/perl ## ## lb.pl -- ·Îµå¹ë·±½Ì ½ºÅ©¸³Æ® ## $| = 1; $name = "www"; # ±âº» È£½ºÆ®¸í $first = 1; # ù¹ø° ¼¹ö (ÀÚ½ÅÀÌ 0À̱⠶§¹®¿¡, 0À» »ç¿ëÇÏÁö ¾Ê´Â´Ù) $last = 5; # round-robin¿¡¼ ¸¶Áö¸· ¼¹ö $domain = "foo.dom"; # µµ¸ÞÀθí $cnt = 0; while (<STDIN>) { $cnt = (($cnt+1) % ($last+1-$first)); $server = sprintf("%s%d.%s", $name, $cnt+$first, $domain); print "http://$server/$_"; } ##EOF##
¸¶Áö¸· ÁÖÀÇ: ¿Ö ÀÌ ¹æ¹ýÀÌ À¯¿ëÇÑ°¡? www0.foo.com
¿¡ ºÎ´ãÀÌ °¡Áö¾Ê´Â°¡? ¹°·Ð, ºÎ´ãÀÌ µÈ´Ù. ±×·¯³ª ´Ü¼øÇÑ proxy throughput ¿äû¸¸ Çϱ⶧¹®¿¡ ±¦Âú´Ù! ¸ðµç SSI, CGI, ePerl µîÀº ÀüÀûÀ¸·Î ´Ù¸¥ ¼¹ö°¡ ó¸®ÇÑ´Ù. ÀÌ°ÍÀÌ ÇÙ½ÉÀÌ´Ù. -
Çϵå¿þ¾î/TCP Round-Robin
Çϵå¿þ¾î¸¦ »ç¿ëÇÑ ÇØ°áÃ¥µµ ÀÖ´Ù. Cisco´Â TCP/IP ¼öÁØ¿¡¼ ·Îµå¹ë·±½ÌÀ» ÇÏ´Â LocalDirector¶ó´Â ±«¹°À» ÆÇ´Ù. ½ÇÁ¦·Î´Â À¥¼¹ö±º ¾Õ´Ü¿¡ À§Ä¡ÇÏ´Â ÀÏÁ¾ÀÇ È¸·Î¼öÁØ °ÔÀÌÆ®¿þÀÌ´Ù. ÀÚ±ÝÀÌ ÃæºÐÇÏ°í °í¼º´É ÇØ°áÃ¥ÀÌ ÇÊ¿äÇÏ´Ù¸é ÀÌ°ÍÀ» »ç¿ëÇ϶ó.
-
DNS Round-Robin
- »óȲ¼³¸í:
-
³×Æ®¿÷¿¡´Â ¸ÚÁø CGI ÇÁ·Î±×·¥µéÀÌ ¸¹´Ù. ±×·¯³ª »ç¿ëÇϱ⠹ø°Å·¯¿ö¼ ¸¹Àº À¥°ü¸®ÀÚ°¡ »ç¿ëÇÏÁö ¾Ê´Â´Ù. ¾ÆÆÄÄ¡ÀÇ MIME-type¿¡ µû¸¥ Action Çڵ鷯 ±â´Éµµ CGI ÇÁ·Î±×·¥ÀÌ Æ¯º°ÇÑ URLÀ» (Á¤È®È÷
PATH_INFO
¿ÍQUERY_STRINGS
) ÇÁ·Î±×·¥ÀÇ ÀÔ·ÂÀ¸·Î »ç¿ëÇÏÁö ¾ÊÀ» ¶§¸¸ ÀûÀýÇÏ´Ù. ¸ÕÀú, È®ÀåÀÚ°¡ (secure CGI¸¦ ÁÙ¿©).scgi
ÀÎ ÆÄÀÏÀ» À¯¸íÇÑcgiwrap
ÇÁ·Î±×·¥À¸·Î ó¸®ÇϱâÀ§ÇØ »õ·Î¿î typeÀ» ¼³Á¤ÇÑ´Ù. ¹®Á¦´Â (À§¿¡¼ º») ÀÏ°üµÈ URL ±¸Á¶¸¦ »ç¿ëÇÏ´Â °æ¿ì »ç¿ëÀÚ È¨µð·ºÅ丮°¡/u/user/foo/bar.scgi
°°Àº URLÀÎ Á¡ÀÌ´Ù.cgiwrap
´Â/~user/foo/bar.scgi/
Çü½ÄÀÇ URLÀ» ¿øÇϱ⶧¹®ÀÌ´Ù. ´ÙÀ½ ±ÔÄ¢ÀÌ ¹®Á¦¸¦ ÇØ°áÇÑ´Ù:RewriteRule ^/[uge]/([^/]+)/\.www/(.+)\.scgi(.*) ... ... /internal/cgi/user/cgiwrap/~$1/$2.scgi$3 [NS,T=application/x-http-cgi]
ÀÌÁ¦ ´Ù¸¥ ¸ÚÁø ÇÁ·Î±×·¥, (URL ÇÏÀ§Æ®¸®¿¡ ´ëÇÑ
access.log
¸¦ Ãâ·ÂÇÏ´Â)wwwlog
¿Í (URL ÇÏÀ§Æ®¸®¿¡ Glimpse¸¦ ½ÇÇàÇÏ´Â)wwwidx
°¡ ÀÖ´Ù°í °¡Á¤ÇÏÀÚ. ¿ì¸®´Â ÇÁ·Î±×·¥¿¡°Ô ÀÛ¾÷ÇÒ ´ë»óÀÎ URL ¿µ¿ªÀ» ¾Ë·ÁÁà¾ß ÇÑ´Ù. ±×·¯³ª ¿äûÇÒ¶§¸¶´Ù Ç×»ó Àû¾îÁà¾ß Çϱ⶧¹®¿¡ ±ò²ûÇÏÁö ¾Ê´Ù. Áï, º¸Åë/u/user/foo/
¿¡ ´ëÇØswwidx
ÇÁ·Î±×·¥À» ½ÇÇàÇÑ´Ù¸é ´ÙÀ½°ú °°Àº ¸µÅ©¸¦ »ç¿ëÇÑ´Ù/internal/cgi/user/swwidx?i=/u/user/foo/
±ò²ûÇÏÁö ¾Ê´Ù. ¸µÅ©¿¡ ¿µ¿ªÀÇ À§Ä¡¿Í CGI À§Ä¡¸¦ ¸ðµÎ Àû¾î¾ß Çϱ⶧¹®ÀÌ´Ù. ¿µ¿ªÀ» À籸¼ºÇÑ´Ù¸é ¿©·¯ ÇÏÀÌÆÛ¸µÅ©¸¦ ¼öÁ¤Çϴµ¥ ¸¹Àº ½Ã°£ÀÌ °É¸± °ÍÀÌ´Ù.
- ÇØ°áÃ¥:
-
ÇØ°áÃ¥Àº ÀÚµ¿À¸·Î ÀûÀýÇÑ CGI¸¦ ½ÇÇàÇÏ´Â »õ·Î¿î Ưº°ÇÑ URL Çü½ÄÀ» ¸¸µå´Â °ÍÀÌ´Ù. ´ÙÀ½°ú °°ÀÌ ¼³Á¤ÇÑ´Ù:
RewriteRule ^/([uge])/([^/]+)(/?.*)/\* /internal/cgi/user/wwwidx?i=/$1/$2$3/ RewriteRule ^/([uge])/([^/]+)(/?.*):log /internal/cgi/user/wwwlog?f=/$1/$2$3
ÀÌÁ¦
/u/user/foo/
À» °Ë»öÇÏ´Â ¸µÅ©´Â ´ÙÀ½°ú °°´ÙHREF="*" /u/user/foo/* (???)
³»ºÎÀûÀ¸·Î ´ÙÀ½°ú °°ÀÌ ÀÚµ¿º¯È¯µÈ´Ù
/internal/cgi/user/wwwidx?i=/u/user/foo/
°°Àº ¹æ¹ýÀ¸·Î ¸µÅ© µÚ¿¡
:log
¸¦ »ç¿ëÇÏ¿© Á¢±Ù ·Î±× CGI ÇÁ·Î±×·¥À» ½ÇÇàÇÒ ¼ö ÀÖ´Ù.
- »óȲ¼³¸í:
-
¾î¶»°Ô ºê¶ó¿ìÀú¿Í »ç¿ëÀÚ°¡ ¸ð¸£°Ô ÀÚ¿¬½º·´°Ô Á¤Àû ÆäÀÌÁö
foo.html
À» µ¿ÀûÀÎfoo.cgi
·Î º¯°æÇÒ ¼ö ÀÖ³ª. - ÇØ°áÃ¥:
-
URLÀ» CGI ½ºÅ©¸³Æ®·Î ÀçÀÛ¼ºÇÏ°í, MIME-typeÀ» ¼öÁ¤ÇÏ¿© CGI ½ºÅ©¸³Æ®·Î ½ÇÇàÇÏ°Ô ÇÑ´Ù. ±×·¡¼
/~quux/foo.html
¸¦ ¿äûÇÏ¸é ³»ºÎÀûÀ¸·Î/~quux/foo.cgi
¸¦ ½ÇÇàÇÏ°Ô µÈ´Ù.RewriteEngine on RewriteBase /~quux/ RewriteRule ^foo\.html$ foo.cgi [T=application/x-httpd-cgi]
- »óȲ¼³¸í:
-
ÀÌ ¹æ¹ýÀº ½Ç·Î ºñ±âÀÌ´Ù: µ¿ÀûÀ¸·Î ÆäÀÌÁö¸¦ »ý¼ºÇÏÁö¸¸, Á¤ÀûÀ¸·Î ÆäÀÌÁö¸¦ ¼ºñ½ºÇÑ´Ù. Áï, ÆäÀÌÁö´Â ¼ø¼öÇÏ°Ô (ÆÄÀϽýºÅÛ¿¡¼ ÀÐÀº ³»¿ëÀ» ±×´ë·Î) Á¤Àû ÆäÀÌÁö·Î Àü´ÞµÇÁö¸¸, ¾øÀ» °æ¿ì À¥¼¹ö°¡ µ¿ÀûÀ¸·Î »ý¼ºÇÑ´Ù. ±×·¯¸é ´©°¡ (ȤÀº cron ÀÛ¾÷ÀÌ) Á¤Àû ÄÁÅÙÃ÷¸¦ Áö¿ìÁö¾Ê´Â ÇÑ CGI°¡ »ý¼ºÇÑ ÆäÀÌÁö¸¦ Á¤ÀûÀ¸·Î ¼ºñ½ºÇÑ´Ù. ÄÁÅÙÃ÷¸¦ Áö¿ì¸é ³»¿ëÀ» °»½ÅÇÑ´Ù.
- ÇØ°áÃ¥:
-
´ÙÀ½ ±ÔÄ¢À» »ç¿ëÇÑ´Ù:
RewriteCond %{REQUEST_FILENAME} !-s RewriteRule ^page\.html$ page.cgi [T=application/x-httpd-cgi,L]
¿©±â¼
page.html
¸¦ ¿äûÇÒ¶§page.html
ÀÌ ¾ø°Å³ª ÆÄÀÏÅ©±â°¡ 0ÀÎ °æ¿ì ³»ºÎÀûÀ¸·Îpage.cgi
¸¦ ½ÇÇàÇÑ´Ù. ¿©±â¼ ºñ°áÀºpage.cgi
°¡ ÀϹÝÀûÀÎ CGI ½ºÅ©¸³Æ®¿Í °°ÀÌSTDOUT
¿¡ Ãâ·ÂÇÏ°í, Ãß°¡·Î Ãâ·ÂÀ»page.html
ÆÄÀÏ¿¡ Àû´Â´Ù. Çѹø ½ÇÇàÇÑÈÄ ¼¹ö´Âpage.html
ÀÇ Á¤º¸¸¦ º¸³½´Ù. À¥°ü¸®ÀÚ°¡ °Àç·Î ³»¿ëÀ» °»½ÅÇÏ°í ½Í´Ù¸é, (º¸Åë cron ÀÛ¾÷ÀÌ)page.html
À» Áö¿ì±â¸¸ ÇÏ¸é µÈ´Ù.
- »óȲ¼³¸í:
-
º¹ÀâÇÑ À¥ÆäÀÌÁö¸¦ ¸¸µé¶§ ÆíÁýÀÚ°¡ ³»¿ëÀ» ¼öÁ¤ÇÒ ¶§¸¶´Ù ÀÚµ¿À¸·Î ÆäÀÌÁö¸¦ »õ·Î °íħÇÏ´Â À¥ºê¶ó¿ìÀú°¡ ÀÖÀ¸¸é ¾ó¸¶³ª ÁÁÀ»±î? ºÒ°¡´ÉÇÑ°¡?
- ÇØ°áÃ¥:
-
°¡´ÉÇÏ´Ù! MIME multipart ±â´É°ú À¥¼¹ö NPH ±â´É,
mod_rewrite ÀÇ URL Á¶ÀÛ ´É·ÂÀ» °áÇÕÇÏ¸é µÈ´Ù. ¸ÕÀú, »õ·Î¿î URL ±â´ÉÀ» ¸¸µç´Ù: URL¿¡:refresh
¸¦ Ãß°¡Çϱ⸸ Çϸé ÆÄÀϽýºÅÛ¿¡¼ ¼öÁ¤µÉ ¶§¸¶´Ù »õ·Î °íħÇÑ´Ù.RewriteRule ^(/[uge]/[^/]+/?.*):refresh /internal/cgi/apache/nph-refresh?f=$1
ÀÌÁ¦ ´ÙÀ½ URL¿¡ Á¢±ÙÇϸé
/u/foo/bar/page.html:refresh
´ÙÀ½ URLÀ» ³»ºÎÀûÀ¸·Î ºÎ¸¥´Ù
/internal/cgi/apache/nph-refresh?f=/u/foo/bar/page.html
ÀÌÁ¦ NPH-CGI ½ºÅ©¸³Æ®¸¸ ³²¾Ò´Ù. º¸Åë "µ¶ÀÚ¿¡°Ô ¿¬½ÀÀ¸·Î ³²°ÜµÒ"À̶ó°í ¸»ÇÏÁö¸¸ ;-) ³ª´Â À̰͵µ Á¦°øÇÑ´Ù.
#!/sw/bin/perl ## ## nph-refresh -- NPH/CGI script for auto refreshing pages ## Copyright (c) 1997 Ralf S. Engelschall, All Rights Reserved. ## $| = 1; # split the QUERY_STRING variable @pairs = split(/&/, $ENV{'QUERY_STRING'}); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $name =~ tr/A-Z/a-z/; $name = 'QS_' . $name; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; eval "\$$name = \"$value\""; } $QS_s = 1 if ($QS_s eq ''); $QS_n = 3600 if ($QS_n eq ''); if ($QS_f eq '') { print "HTTP/1.0 200 OK\n"; print "Content-type: text/html\n\n"; print "<b>ERROR</b>: No file given\n"; exit(0); } if (! -f $QS_f) { print "HTTP/1.0 200 OK\n"; print "Content-type: text/html\n\n"; print "<b>ERROR</b>: File $QS_f not found\n"; exit(0); } sub print_http_headers_multipart_begin { print "HTTP/1.0 200 OK\n"; $bound = "ThisRandomString12345"; print "Content-type: multipart/x-mixed-replace;boundary=$bound\n"; &print_http_headers_multipart_next; } sub print_http_headers_multipart_next { print "\n--$bound\n"; } sub print_http_headers_multipart_end { print "\n--$bound--\n"; } sub displayhtml { local($buffer) = @_; $len = length($buffer); print "Content-type: text/html\n"; print "Content-length: $len\n\n"; print $buffer; } sub readfile { local($file) = @_; local(*FP, $size, $buffer, $bytes); ($x, $x, $x, $x, $x, $x, $x, $size) = stat($file); $size = sprintf("%d", $size); open(FP, "<$file"); $bytes = sysread(FP, $buffer, $size); close(FP); return $buffer; } $buffer = &readfile($QS_f); &print_http_headers_multipart_begin; &displayhtml($buffer); sub mystat { local($file) = $_[0]; local($time); ($x, $x, $x, $x, $x, $x, $x, $x, $x, $mtime) = stat($file); return $mtime; } $mtimeL = &mystat($QS_f); $mtime = $mtime; for ($n = 0; $n < $QS_n; $n++) { while (1) { $mtime = &mystat($QS_f); if ($mtime ne $mtimeL) { $mtimeL = $mtime; sleep(2); $buffer = &readfile($QS_f); &print_http_headers_multipart_next; &displayhtml($buffer); sleep(5); $mtimeL = &mystat($QS_f); last; } sleep($QS_s); } } &print_http_headers_multipart_end; exit(0); ##EOF##
- »óȲ¼³¸í:
-
°¡»óÈ£½ºÆ®°¡ ¸î°³¸¸ ÀÖ´Ù¸é ¾ÆÆÄÄ¡ÀÇ
VirtualHost ±â´ÉÀÌ Àß µ¿ÀÛÇÑ´Ù. ±×·¯³ª °¡»óÈ£½ºÆ®°¡ ¼ö¹é°³ ÀÖ´Â ISP¶ó¸é ÀÌ ±â´ÉÀÌ ÃÖ¼±Àº ¾Æ´Ï´Ù. - ÇØ°áÃ¥:
-
ÀÌ ±â´ÉÀ» Á¦°øÇÏ·Á¸é Proxy Throughput ±â´ÉÀ» (Ç÷¡±×
[P]
) »ç¿ëÇÏ¿© ¿ÜºÎ À¥ÆäÀÌÁö ȤÀº Àüü ¿ÜºÎ À¥¿µ¿ªÀ» ¿ì¸®ÀÇ À̸§°ø°£¿¡ ´ëÀÀÇÑ´Ù:## ## vhost.map ## www.vhost1.dom:80 /path/to/docroot/vhost1 www.vhost2.dom:80 /path/to/docroot/vhost2 : www.vhostN.dom:80 /path/to/docroot/vhostN
## ## httpd.conf ## : # ¸®´ÙÀÌ·ºÆ®ÇÒ¶§ Á¤±Ô È£½ºÆ®¸íÀ» »ç¿ëÇÑ´Ù. UseCanonicalName on : # °¡»óÈ£½ºÆ®¸¦ CLF Çü½Ä ¾Õ¿¡ Ãß°¡ÇÑ´Ù CustomLog /path/to/access_log "%{VHOST}e %h %l %u %t \"%r\" %>s %b" : # ÁÖ¼¹ö¿¡¼ ÀçÀÛ¼º ¿£ÁøÀ» »ç¿ëÇÑ´Ù RewriteEngine on # µÎ ¸ÊÀ» Á¤ÀÇÇÑ´Ù: Çϳª´Â URLÀ» °íÄ¡°í, # ´Ù¸¥ Çϳª´Â °¡»óÈ£½ºÆ®º° DocumentRoot¸¦ # Á¤ÀÇÇÑ´Ù. RewriteMap lowercase int:tolower RewriteMap vhost txt:/path/to/vhost.map # ÀÌÁ¦ Å©°í º¹ÀâÇÑ ±ÔÄ¢ ÇÑ°³¸¦ »ç¿ëÇÏ¿© # °¡»óÈ£½ºÆ®·Î ´ëÀÀÇÑ´Ù. # # 1. °¡»óÈ£½ºÆ®µéÀÌ °°ÀÌ »ç¿ëÇÏ´Â À§Ä¡´Â ´ëÀÀÇÏÁö ¾Ê´Â´Ù RewriteCond %{REQUEST_URL} !^/commonurl1/.* RewriteCond %{REQUEST_URL} !^/commonurl2/.* : RewriteCond %{REQUEST_URL} !^/commonurlN/.* # # 2. ¿ì¸®°¡ ÇöÀç »ç¿ëÇÏ´Â ¹æ¹ýÀÌ Host Çì´õ¸¦ # °¡»óÈ£½ºÆ®¸¦ Áö¿øÇϹǷΠ# Host Çì´õ°¡ ÀÖ´ÂÁö È®ÀÎÇÑ´Ù RewriteCond %{HTTP_HOST} !^$ # # 3. È£½ºÆ®¸íÀ» ¼Ò¹®ÀÚ·Î ¸¸µç´Ù RewriteCond ${lowercase:%{HTTP_HOST}|NONE} ^(.+)$ # # 4. vhost.map¿¡¼ È£½ºÆ®¸íÀ» ã°í # °æ·ÎÀ϶§¸¸ ±â¾ïÇÑ´Ù # (À§¿¡¼ "NONE"Àº ¾Æ´Ï´Ù) RewriteCond ${vhost:%1} ^(/.*)$ # # 5. ¸¶Áö¸·À¸·Î URLÀ» ¹®¼ À§Ä¡·Î ´ëÀÀÇÏ°í # ·Î±×¿¡ ³²±â±âÀ§ÇØ °¡»óÈ£½ºÆ®¸¦ ±â¾ïÇØ µÐ´Ù RewriteRule ^/(.*)$ %1/$1 [E=VHOST:${lowercase:%{HTTP_HOST}}] :