Save 37% off PRO during our Black Friday Sale! »

PEPABO EC tech conference ngx_mruby 2020

PEPABO EC tech conference ngx_mruby 2020

5a2b3cc2950f3ee86d535e561ffd72a5?s=128

Teppei Yano

June 24, 2020
Tweet

Transcript

  1. 1 Χϥʔϛʔγϣοϓͱ ngx_mruby 2020 2020-06-24 ϖύϘ EC ςοΫΧϯϑΝϨϯε ECࣄۀ෦ Χϥʔϛʔγϣοϓάϧʔϓ

    αʔϏεج൫νʔϜ ໼໺ ఩ฏ @yano3
  2. 2 2 ໼໺ ఩ฏ Yano Teppei @yano3 ʢ΍ͷ͞Μʣ ECࣄۀ෦ Χϥʔϛʔγϣοϓάϧʔϓ

    αʔϏεج൫νʔϜ • https://twitter.com/yano3 • https://github.com/yano3 ⛷ ઇࢁ͕޷͖ ❄ ❄ ❄
  3. 3 ngx_mruby Section 1 3

  4. 4 ngx_mruby ͱ͸ A Fast and Memory-Efficient Nginx Extension Mechanism

    Scripting with mruby. 4
  5. 5 ngx_mruby ͱ͸ 5 • mruby ͸૊ΈࠐΈ޲͚ͷܰྔͳ Ruby ࣮૷ •

    Ruby εΫϦϓτͰ nginx Λ֦ுՄೳ • ྨࣅͷ΋ͷͱͯ͠ lua-nginx-module (OpenResty)
  6. 6 ࠓ·Ͱͷ ngx_mruby ར༻ࣄྫ Section 2 6

  7. 7 ࠓ·Ͱͷ ngx_mruby ར༻ࣄྫ ಠࣗυϝΠϯৗ࣌SSLͷಈతূ໌ॻಡΈࠐΈ ৗ࣌SSL https://shop-pro.jp/ssl/ ΞʔΩςΫνϟ https://speakerdeck.com/hfm/gmo-hoscon-2016 ʢ΄΅ಉ͡ΞʔΩςΫνϟΛ঺հͨ͠ࢿྉʣ

    7
  8. 8 ৽ͨͳ ngx_mruby ར༻ࣄྫ Section 3 8

  9. 9 ৽ͨͳ ngx_mruby ར༻ࣄྫ ͱɺͦͷલʹ... ngx_mruby Λ࢖࣮ͬͨ૷ͷલఏͱͳͬͨ৽ػೳ ΧϥʔϛʔWPΦϓγϣϯ ʹ͍ͭͯ 9

  10. 10 ΧϥʔϛʔWPΦϓγϣϯ Section 4 10

  11. 11 ΧϥʔϛʔWPΦϓγϣϯ ΧϥʔϛʔΞϓϦετΞ͔ΒΠϯετʔϧ https://app.shop-pro.jp/apps/74 11 ΧϥʔϛʔWPΦϓγϣϯͱ͸

  12. 12 12 ΧϥʔϛʔWPΦϓγϣϯͱ͸ γϣοϓͷυϝΠϯ https://shop.example.com ͷԼͷύεʹ WordPress Λදࣔ https://shop.example.com/apps/note/ কདྷ͸ผͷύεͰଞͷ

    Web ΞϓϦͷఏڙ͢Δ͜ ͱ΋ߟྀͨ͠ઃܭ ΧϥʔϛʔWPΦϓγϣϯ
  13. 13 13 ΞʔΩςΫνϟ ΧϥʔϛʔWPΦϓγϣϯ

  14. 14 14 ΞʔΩςΫνϟ ௨ৗͷγϣοϓΛදࣔ ΧϥʔϛʔWPΦϓγϣϯ

  15. 15 15 ΞʔΩςΫνϟ • /apps ΛؚΉύε͸ app-proxy ʹϓ ϩΩγ •

    app-proxy ͸͞ΒʹύεʹΑͬͯ ΞοϓετϦʔϜͷ Web ΞϓϦέʔ γϣϯʹϓϩΩγʢ /note ͳΒϩϦ ϙοϓʂϚωʔδυΫϥ΢υͷΤϯ υϙΠϯτ΁※ʣ ※ WordPress Λىಈ͢ΔόοΫΤϯυͱͯ͠ϩϦϙοϓʂ ϚωʔδυΫϥ΢υΛར༻͍ͯ͠·͢ɻ https://note.com/mclolipopjp/n/ncd713843e4f2 ΧϥʔϛʔWPΦϓγϣϯ
  16. 16 16 ΞʔΩςΫνϟ • ϩϦϙοϓʂϚωʔδυΫϥ΢υଆ Ͱ host ϔομʹΑΓͦΕͧΕͷ WordPress ʹϓϩΩγ

    ΧϥʔϛʔWPΦϓγϣϯ
  17. 17 17 ngx_mruby ͕ొ৔͢Δ2ͭͷϙΠϯτ • ಈతϧʔςΟϯά • cookie ͷϑΟϧλϦϯά ΧϥʔϛʔWPΦϓγϣϯ

  18. 18 ಈతϧʔςΟϯά Section 5 18

  19. 19 ಈతϧʔςΟϯά 19 ͜ͷ΁Μͷ͓࿩ ઌఔͷਤͷ...

  20. 20 20 ՝୊ • γϣοϓʢͷυϝΠϯʣͱύεʹΑͬͯҟͳ ΔΞοϓετϦʔϜʹϓϩΩγ͢Δ • ΧϥʔϛʔWPΦϓγϣϯΛ࢖͍ͬͯͳ͍ γϣοϓ͸ϓϩΩγ͠ͳ͍ʢ404ʣ ಈతϧʔςΟϯά

  21. 21 21 ΞϓϦετΞ͸ API Λհͯ͠Πϯετʔϧ৘ใΛ࡞੒ ಈతϧʔςΟϯά

  22. 22 22 WPΦϓγϣϯͷ Web ΞϓϦ͸ API ͔Βγϣοϓ৘ใΛऔಘ͠... ಈతϧʔςΟϯά

  23. 23 23 γϣοϓͷυϝΠϯͱඥ෇͍ͨ WordPress Λ࡞੒ ಈతϧʔςΟϯά

  24. 24 24 ngx_mruby ϙΠϯτ

  25. 25 25 app-proxy ্ͷ ngx_mruby ͸υϝΠϯͱύε͔ΒϓϩΩγઌΛฦ͢ API ʹϦΫΤετ ಈతϧʔςΟϯά

  26. 26 26 ngx_mruby ʹΑΓϓϩΩγઌʹಈతʹΞοϓετϦʔϜΛઃఆ ಈతϧʔςΟϯά

  27. 27 27 ngx_mruby Ͱղܾʂ • ϦΫΤετͷॲཧதʹ http Ͱ API ʹϦΫΤε

    τ • ϓϩΩγͷΞοϓετϦʔϜΛಈతʹมߋ ಈతϧʔςΟϯά
  28. 28 cookie ͷ ϑΟϧλϦϯά Section 6 28

  29. 29 cookie ͷϑΟϧλϦϯά 29 ͜ͷ΁Μͷ͓࿩ ઌఔͷਤͷ...

  30. 30 30 ՝୊ • ಉ͡υϝΠϯ্ʹγϣοϓͱ WordPress ͕ଘ ࡏ͢ΔͨΊɺγϣοϓͷ cookie Λ

    WordPress ͔Βࢀরɺૢ࡞Ͱ͖ͯ͠·͏ • WordPress ͷ৐ͬऔΓ΍ѱҙͷ͋ΔϓϥάΠ ϯ͕ଘࡏ͢Δͱ໰୊ʹͳΔ cookie ͷϑΟϧλϦϯά
  31. 31 31 ղܾͷΞϓϩʔν • Χϥʔϛʔγϣοϓͷ cookie ʹ͸໊લʹಛఆ ͷϓϨϑΟοΫΛ෇͚Δ • app-proxy

    Ͱ্هʹ֘౰͢Δ໊લͷ cookie ͸ cookie ϔομ set-cookie ϔομͱ΋ʹϑΟ ϧλ͢Δ cookie ͷϑΟϧλϦϯά
  32. 32 32 ngx_mruby ϙΠϯτ

  33. 33 33 cookie ͷϑΟϧλϦϯά ΞʔΩςΫνϟ

  34. 34 34 • ΞϓϦέʔγϣϯαʔό ͷલ໘ʹ഑ஔͨ͠ ngx_mruby Ͱ cookie ໊ͷ ϓϨϑΟοΫεΛண୤

    • Web ΞϓϦέʔγϣϯʹ ͸खΛೖΕΔඞཁͳ͠ cookie ͷϑΟϧλϦϯά
  35. 35 35 • ϓϨϑΟοΫεͷ෇͍ͨ ໊લͷ cookie ͸ app- proxy ͰϑΟϧλ͠

    WordPress ΁౉͞ͳ͍ • WordPress ͔Βҙਤతʹ ϓϨϑΟοΫεΛ͚ͭͨ ໊લͰ set-cookie ϔομ ͕ૹΒΕͯ΋ϒϩοΫ cookie ͷϑΟϧλϦϯά
  36. 36 36 ngx_mruby Ͱղܾʂ • cookie ϔομΛؚΉϦΫΤετɺϨεϙϯε ֤ϔομΛࢀরɺॻ͖ࠐΈͰ͖Δ αϯϓϧίʔυ •

    https://github.com/yano3/kankara/tree/master/ngx_mruby/cookie_add_prefix • https://github.com/yano3/kankara/tree/master/ngx_mruby/cookie_filter_by_prefix cookie ͷϑΟϧλϦϯά
  37. 37 ·ͱΊ Section 7 37

  38. 38 38 ·ͱΊ 2020೥ͷ ngx_mruby on Χϥʔϛʔγϣοϓ • ৽ͨʹ2ͭͷར༻ࣄྫΛ঺հ ◦

    ಈతϧʔςΟϯά ◦ cookie ϑΟϧλϦϯά • ࠓޙ΋దࡐదॴͰ׆༻͍͖ͯ͠·͢ ngx_mruby ศརʂ