Plack :: ¹Ìµé¿þ¾î :: ReverseProxyPath.Ŭ¶óÀ̾ðÆ®¸¦ Á÷¸éÇÏ°ÔÇÏ´Â ÇÁ·Ï½Ã env Á¶Á¤ | |
Áö±Ý ´Ù¿î·Îµå |
Plack :: ¹Ìµé¿þ¾î :: ReverseProxyPath. ¼øÀ§ ¹× ¿ä¾à
±¤°í
- ƯÇã:
- Perl Artistic License
- °¡°Ý:
- FREE
- °Ô½ÃÀÚ À̸§:
- Brad Bowman
- °Ô½ÃÀÚ À¥»çÀÌÆ®:
- http://search.cpan.org/~bowmanbs/
Plack :: ¹Ìµé¿þ¾î :: ReverseProxyPath. ű×
Plack :: ¹Ìµé¿þ¾î :: ReverseProxyPath. ¼³¸í
»ç¿ë »ç·Ê : ¿ª¹æÇâ ÇÁ·Ï½Ã / ÇÏÀ§ / °æ·Î / http : // 0 : 5000 / ±âŸ / °æ·Î / ÀÌ ¹Ìµé¿þ¾î´Â ¹é¿£µå¿¡ ¾É¾Æ¼ ÇÁ·Ï½Ã°¡ º¸³½ Çì´õ¸¦ »ç¿ëÇÏ¿© ¹é ¿£µå App.plack :: ¹Ìµé¿þ¾î :: ReverseProxy´Â È£½ºÆ®, Æ÷Æ® ¹× scheme.Plack :: ¹Ìµé¿þ¾î :: ReverseProxyPath´Â °æ·Î 󸮸¦ Ãß°¡ÇÕ´Ï´Ù. ¸ñÇ¥´Â ÇÁ·Ï½Ã ¹é ¿£µå ¾ÛÀÌ Å¬¶óÀ̾ðÆ® Á÷¸é URLÀ» À籸¼ºÇÏ°í »ç¿ëÇÒ ¼öÀÖ°ÔÇÏ´Â °ÍÀÔ´Ï´Ù. ReverseProxy ´ëºÎºÐÀÇ ÀÛ¾÷°ú ReverseProxyPath°¡ °æ·Î¸¦ ¼öÇàÇÕ´Ï´Ù. ³»ºÎ ¾ÛÀº $ Req-> Base¸¦ »ç¿ëÇÏ¿© ÄíÅ°¸¦ ¸®µð·º¼Ç, ¼³Á¤ ÄíÅ° ¹× Like¸¦ ´Ü¼øÈ÷ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. ¿ª¹æÇâ ÇÁ·Ï½Ã ¸®µå¸¦ È¥µ¿À¸·Î ãÀ» ¼ö ÀÖÀ¸¹Ç·Î ÇÁ·±Æ® ¿£µå¸¦ »ç¿ëÇÏ¿© ¿ª¹æÇâ ÇÁ·Ï½Ã (¿¹ : Squid)¸¦ ÂüÁ¶ÇÏ¿© ÇÁ·±Æ® ¿£µå¸¦ »ç¿ëÇÕ´Ï´Ù. Ŭ¶óÀ̾ðÆ®°¡ ¸ÕÀú È÷Æ®Çϸç PSGI ÀÀ¿ë ÇÁ·Î±×·¥ (¿¹ : Starman) .plack :: ¹Ìµé¿þ¾î :: ReverseproxyPath´Â ÇÁ·ÐÆ® ¿£µåÀÇ Çì´õ¸¦ ±â¹ÝÀ¸·Î script_name ¹× path_info¸¦ Á¶Á¤ÇÏ¿© ³»ºÎ ¾ÛÀÌ ¼ö ÀÖ½À´Ï´Ù. °Å±â¿¡ ÇÁ·Ï½Ã°¡¾ø´Â ôÇϽʽÿÀ. ÀÌ°ÍÀº ÇÁ·Ï½Ã¿Í Àüü ¼¹ö°¡ ¾Æ´Ï¶ó ´õ ±íÀº °æ·Î ¸¸ »ç¿ëÇÒ ¶§ À¯¿ëÇÕ´Ï´Ù. apache Á¶°Ç : proxypass / mirror / foo / http : // localhost : 5000 / bar / plack :: middleware :: Scheme, È£½ºÆ® ¹× Æ÷Æ® ȯ°æ ¼Ó¼º¿¡ ÇØ´çÇÏ´Â Á¶Á¤À» ¼öÇàÇÏ´Â ReverseProxy.Synopsisgenerally °£´ÜÇÑ Áß°£ µµÀڱ⸦ »ç¿ëÇϽʽÿÀ : "ReverseProxy"¸¦ È°¼ºÈÇϽʽÿÀ. "ReverseProxyPath"È°¼ºÈ; ¾Æ·¡´Â Dummle Reverse Proxy ÇÁ·±Æ® ¿£µå¿Í ReverseProxyPath¸¦ »ç¿ëÇÏ¿© ¹é ¿£µå¸¦ ¸ðµÎ Æ÷ÇÔÇÏ´Â Á¤±³ÇÑ ¿¹ÀÔ´Ï´Ù. PLACK_SERVER = Starman Perl -x -ilib ./lib/plack/middleware/reverseProxyPath.pm (¾Æ·¡ Ãâ·Â) #! perl -mplack :: runner #line 85 sub mw (); Plack :: Builder¸¦ »ç¿ëÇϽʽÿÀ. # ¿ª¹æÇâ ÇÁ·Ï½Ã (perlbal, varnish, apache, squid) # x-forwarded-script-name°ú x-traversal-path Çì´õ¸¦ º¸³»·Á¸é # #ÀÌ ¿¹Á¦´Â PLACK :: APP :: PROXY¸¦ »ç¿ëÇÏ¿© ´ÙÀ½°ú °°½À´Ï´Ù. SUB PROXY_BUILDER {PLACK :: APP :: ÇÁ·Ï½Ã ÇÊ¿ä; # ÀÌ°ÍÀº https : // mount "http : // localhost / fepath / from"=> builder {mw {my ($ ¾Û, $ env) = @_; # reaversproxypath $ env -> { 'http_forwarded_script_name'} = '/ fepath / from'; $ env -> { 'http_x_traversal_path'} = '/ bePath / to'; # $ ENV-> { 'http_x_forwarded_host'} = 'Somehost'¿¡ ´ëÇÑ # Çì´õ. # $ env -> { 'http_x_forwarded_port'} = 443; "$ env -> { 'psgi.multiprocess'}! $ env -> {psgi.multithread '}; $ ¾Û -> ($ env); }; Plack :: App :: Proxy-> New (Remote => http : // 0 : 5000 / bePath / to ') -> to_app; }; }; # Plack Back-End My $ App = Builder {# / BEPath / to / *µµ ÇÁ·Ï½Ã (Á÷Á¢ ¾×¼¼½º ÇÒ ¼ö ÀÖ½À´Ï´Ù) ¸¶¿îÆ® "/ bePath / to"=> Builder {# ±âº» Á¶Á¤ : # 1) http : / / 0 : 5000 / bePath / to / x # ReverseProxy ¼öÁ¤ Scheme / Host / Port Enable "ReverseProxy"; # 2) https : // somehost / bepath / to / x # ReveredProxyPath´Â »õ Çì´õ¸¦ »ç¿ëÇÕ´Ï´Ù. script_name ¹× path_info »ç¿ë "ReverseProxyPath"¸¦ ¼öÁ¤ÇÕ´Ï´Ù. # 3) https : // somepthost / fefath / from / x # $ req-> base + $ req-> °æ·Î´Â Ŭ¶óÀ̾ðÆ® Á÷¸é URL # ÀÌ·¸°Ô URL, ¼³Á¤ ÄíÅ°, À§Ä¡°¡ ¼øÁøÇÑ "/ base" => \ echo_base; mount "/ env"=> \ echo_env; }; mount "/ env"=> \ echo_env; ½Ã³ñ½Ã½º ªÀº (ÇÊ¿ä> 1 ÀÛ¾÷ÀÚ) proxy_builder ()¸¦ À¯ÁöÇϱâ À§ÇØ Àڽſ¡°Ô # ÇÁ·Ï½Ã }; # ½Ã³ñ½Ã½º ¹è°ü : ÇÏÀ§ ECHO_BASE {PLACK :: REQUEST ÇÊ¿ä; , ]} sub echo_env {my ($ env) = @_; , ]} sub mw () {³ªÀÇ $ code = ¿Å±â´Ù; ÇÏÀ§ {My $ App = Shift; ÇÏÀ§ {$ ÄÚµå -> ($ app, @_); }}}; Plack :: Runner-> New-> Run ($ ¾Û); __ end__ # __ end__ # __________________________________________________________________________________e ¹é¿£µå GET http : // localhost : 5000 / bepath / to / base http : // localhost : 5000 / bepath / to / baseproductÀÇ È¨ÆäÀÌÁö
Plack :: ¹Ìµé¿þ¾î :: ReverseProxyPath. °ü·Ã ¼ÒÇÁÆ®¿þ¾î