Slide 1

Slide 1 text

/HJOYNSVCZΛಈ͔͢ LBXBTBLJSCप೥ه೦-5େձ LPOEPUBLFTIJ

Slide 2

Slide 2 text

/HJOYNSVCZΛಈ͔͢ LBXBTBLJ SC प೥ه೦-5େձ LPOEPUBLFTIJ

Slide 3

Slide 3 text

1SPpMF w LPOEPUBLFTIJ w 4PGUXBSF&OHJOFFS w 4JUF3FMJBCJMJUZ&OHJOFFS w DIBTQZ@ w DIBTQZ w DIBTQZ w CMPHDIBTQZNF ༗څফԽதʂ

Slide 4

Slide 4 text

/HJOY w ܰྔͰߴ͍εέʔϥϏϦςΟΛތΔΦʔϓϯιʔεͷ )551αʔόͰ͢ɻʮ͑Μ͡Μ͑ͬ͘͢ʯͱಡΈ·͢ɻ OHJOY࣮ફೖ໳OHJOY

Slide 5

Slide 5 text

/HJOY w ΞΫηε੍ޚ w 63*3FXSJUF w H[JQѹॖ w ϦόʔεϓϩΩγ w -ϩʔυόϥϯε w ίϯςϯπΩϟογϡ w 44-λʔϛωʔγϣϯɺ)551ήʔτ΢ΣΠ w -ʢ5$1ʣϩʔυόϥϯε w ϝʔϧϓϩΩγ OHJOY࣮ફೖ໳OHJOY

Slide 6

Slide 6 text

/HJOY w ΞΫηε੍ޚ w 63*3FXSJUF w H[JQѹॖ w ϦόʔεϓϩΩγ w -ϩʔυόϥϯε w ίϯςϯπΩϟογϡ w 44-λʔϛωʔγϣϯɺ)551ήʔτ΢ΣΠ w -ʢ5$1ʣϩʔυόϥϯε w ϝʔϧϓϩΩγ OHJOY࣮ફೖ໳OHJOY ͳΜͰ΋Ͱ͖͗͢

Slide 7

Slide 7 text

NSVCZ w ૊ΈࠐΈ޲͚ܰྔ3VCZ w 3VCZޓ׵ w ଍Γͳ͍Ϋϥεɾػೳ͋Γ w ݴޠ࢓্༷ͷࠩҟ͋Γ ·ͭ΋ͱΏ͖ͻΖ௚఻ɹ૊ࠐ3VCZʮNSVCZʯͷ͢΂ͯ૯ूฤ

Slide 8

Slide 8 text

OHY@NSVCZ w IUUQTHJUIVCDPNNBUTVNPUPSZOHY@NSVCZ w OHJOYͷNSVCZ֦ு w OHY@MVBͷNSVCZ൛ w NPE@NSVCZͷOHJOY൛

Slide 9

Slide 9 text

/HJOYͷϑΣʔζͱϑοΫϙΠϯτ mruby nginx આ໌ mruby_server_rewrite_handle server rewrite αʔόίϯςΩετͷrewrite find config ֘౰͢Δlocation configΛ୳͢ mruby_rewrite_handler rewrite locationͷrewriteॲཧ post rewrite pre-access mruby_access_handler access ϑΝΠϧ΁ͷΞΫηε post-access try-files try_filesͷॲཧ mruby_content_handler content bodyͷੜ੒ mruby_log_handler log ϩάॻ͖ࠐΈ )551SFRVFTUQSPDFTTJOHQIBTFTJO/HJOYIUUQXXXOHJOYHVUTDPNQIBTFT

Slide 10

Slide 10 text

ʢແବʹʣ΍ͬͨ͜ͱ w p[[CV[[ʹ(&5͢Δͱp[[CV[[ͷ݁ՌΛฦ͢ w SFEJSFDUʹ(&5͢Δͱp[[CV[[ʹϦμΠϨΫτ͢Δ IUUQTHJUIVCDPNDIBTQZWBHSBOUOHJOY

Slide 11

Slide 11 text

͜͜ʹp[[CV[[͕͋Δ͡ΌΖʁ r = Nginx::Request.new n = r.var.arg_n.to_i if n % 15 == 0 ans = "FizzBuzz" elsif n % 3 == 0 ans = "Fizz" elsif n % 5 == 0 ans = "Buzz" else ans = n end Nginx.echo(ans) ʢ΅΍͖ʣIJHIMJHIU࢖͚ͬͨͲΠϚΠνͩͳʜ

Slide 12

Slide 12 text

OHJOYDPOG http { server { location /fizzbuzz { mruby_content_handler /usr/local/nginx/conf/fizzbuzz.rb; } location /redirect { mruby_rewrite_handler_code ' Nginx.redirect "/fizzbuzz", Nginx::HTTP_MOVED_PERMANENTLY '; } } }

Slide 13

Slide 13 text

֬ೝ require 'net/http' (0..30).each{|n| Net::HTTP.get_print("192.168.33.100", "/fizzbuzz?n=#{n}") }

Slide 14

Slide 14 text

খωλ w OJMUP@JͬͯͳΜͰ͢Ͷɻɻɻ [vagrant@nginx ~]$ /usr/local/src/ngx_mruby/mruby/bin/mirb mirb - Embeddable Interactive Ruby Shell > nil.to_i => 0

Slide 15

Slide 15 text

·ͱΊͱࠓޙ w OHJOYDPOG͕ΧΦεʹͳΔ৔߹ʹྑͦ͞͏ w JGσΟϨΫςΟϒ͸͋Δ͚ͲFMTFɺ"/% 03ͳ͍͠ w IUUQͱSVCZ෮श͠Α

Slide 16

Slide 16 text

5IBOLZPV