Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PEPABO EC tech conference ngx_mruby 2020
Search
Teppei Yano
June 24, 2020
Technology
1
1k
PEPABO EC tech conference ngx_mruby 2020
https://pepabo.connpass.com/event/179445/
Teppei Yano
June 24, 2020
Tweet
Share
More Decks by Teppei Yano
See All by Teppei Yano
okara updates
yano3
0
72
create puppet module
yano3
0
52
let me introduce you
yano3
0
98
next stage infrastructure
yano3
1
13k
Dynamic image transformation server Okara BETA
yano3
1
5.6k
calamel-okara-beta
yano3
1
11k
Other Decks in Technology
See All in Technology
コンテンツを支える 若手ゲームクリエイターの アートディレクションの事例紹介 / cagamefi-game
cyberagentdevelopers
PRO
1
130
ネット広告に未来はあるか?「3rd Party Cookie廃止とPrivacy Sandboxの効果検証の裏側」 / third-party-cookie-privacy
cyberagentdevelopers
PRO
1
140
プロポーザルのつくり方 〜個人技編〜 / How to come up with proposals
ohbarye
2
160
マネジメント視点でのre:Invent参加 ~もしCEOがre:Inventに行ったら~
kojiasai
0
490
ABEMA のコンテンツ制作を最適化!生成 AI x クラウド映像編集システム / abema-ai-editor
cyberagentdevelopers
PRO
1
180
10分でわかるfreeeのQA
freee
1
3.4k
WINTICKETアプリで実現した高可用性と高速リリースを支えるエコシステム / winticket-eco-system
cyberagentdevelopers
PRO
1
200
Commitment vs Harrisonism - Keynote for Scrum Niseko 2024
miholovesq
6
1.2k
【技術書典17】OpenFOAM(自宅で極める流体解析)2次元円柱まわりの流れ
kamakiri1225
0
220
AWS re:Inventを徹底的に楽しむためのTips / Tips for thoroughly enjoying AWS re:Invent
yuj1osm
1
580
新卒1年目が挑む!生成AI × マルチエージェントで実現する次世代オンボーディング / operation-ai-onboarding
cyberagentdevelopers
PRO
1
170
生成AIとAWS CDKで実現! 自社ブログレビューの効率化
ymae
2
330
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Gamification - CAS2011
davidbonilla
80
5k
Fireside Chat
paigeccino
32
3k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Building Applications with DynamoDB
mza
90
6.1k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
32
1.8k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
664
120k
Writing Fast Ruby
sferik
626
61k
The Art of Programming - Codeland 2020
erikaheidi
51
13k
Why You Should Never Use an ORM
jnunemaker
PRO
53
9k
Transcript
1 Χϥʔϛʔγϣοϓͱ ngx_mruby 2020 2020-06-24 ϖύϘ EC ςοΫΧϯϑΝϨϯε ECࣄۀ෦ Χϥʔϛʔγϣοϓάϧʔϓ
αʔϏεج൫νʔϜ ฏ @yano3
2 2 ฏ Yano Teppei @yano3 ʢͷ͞Μʣ ECࣄۀ෦ Χϥʔϛʔγϣοϓάϧʔϓ
αʔϏεج൫νʔϜ • https://twitter.com/yano3 • https://github.com/yano3 ⛷ ઇࢁ͕͖ ❄ ❄ ❄
3 ngx_mruby Section 1 3
4 ngx_mruby ͱ A Fast and Memory-Efficient Nginx Extension Mechanism
Scripting with mruby. 4
5 ngx_mruby ͱ 5 • mruby ΈࠐΈ͚ͷܰྔͳ Ruby ࣮ •
Ruby εΫϦϓτͰ nginx Λ֦ுՄೳ • ྨࣅͷͷͱͯ͠ lua-nginx-module (OpenResty)
6 ࠓ·Ͱͷ ngx_mruby ར༻ࣄྫ Section 2 6
7 ࠓ·Ͱͷ ngx_mruby ར༻ࣄྫ ಠࣗυϝΠϯৗ࣌SSLͷಈతূ໌ॻಡΈࠐΈ ৗ࣌SSL https://shop-pro.jp/ssl/ ΞʔΩςΫνϟ https://speakerdeck.com/hfm/gmo-hoscon-2016 ʢ΄΅ಉ͡ΞʔΩςΫνϟΛհͨ͠ࢿྉʣ
7
8 ৽ͨͳ ngx_mruby ར༻ࣄྫ Section 3 8
9 ৽ͨͳ ngx_mruby ར༻ࣄྫ ͱɺͦͷલʹ... ngx_mruby Λ࣮ͬͨͷલఏͱͳͬͨ৽ػೳ ΧϥʔϛʔWPΦϓγϣϯ ʹ͍ͭͯ 9
10 ΧϥʔϛʔWPΦϓγϣϯ Section 4 10
11 ΧϥʔϛʔWPΦϓγϣϯ ΧϥʔϛʔΞϓϦετΞ͔ΒΠϯετʔϧ https://app.shop-pro.jp/apps/74 11 ΧϥʔϛʔWPΦϓγϣϯͱ
12 12 ΧϥʔϛʔWPΦϓγϣϯͱ γϣοϓͷυϝΠϯ https://shop.example.com ͷԼͷύεʹ WordPress Λදࣔ https://shop.example.com/apps/note/ কདྷผͷύεͰଞͷ
Web ΞϓϦͷఏڙ͢Δ͜ ͱߟྀͨ͠ઃܭ ΧϥʔϛʔWPΦϓγϣϯ
13 13 ΞʔΩςΫνϟ ΧϥʔϛʔWPΦϓγϣϯ
14 14 ΞʔΩςΫνϟ ௨ৗͷγϣοϓΛදࣔ ΧϥʔϛʔWPΦϓγϣϯ
15 15 ΞʔΩςΫνϟ • /apps ΛؚΉύε app-proxy ʹϓ ϩΩγ •
app-proxy ͞ΒʹύεʹΑͬͯ ΞοϓετϦʔϜͷ Web ΞϓϦέʔ γϣϯʹϓϩΩγʢ /note ͳΒϩϦ ϙοϓʂϚωʔδυΫϥυͷΤϯ υϙΠϯτ※ʣ ※ WordPress Λىಈ͢ΔόοΫΤϯυͱͯ͠ϩϦϙοϓʂ ϚωʔδυΫϥυΛར༻͍ͯ͠·͢ɻ https://note.com/mclolipopjp/n/ncd713843e4f2 ΧϥʔϛʔWPΦϓγϣϯ
16 16 ΞʔΩςΫνϟ • ϩϦϙοϓʂϚωʔδυΫϥυଆ Ͱ host ϔομʹΑΓͦΕͧΕͷ WordPress ʹϓϩΩγ
ΧϥʔϛʔWPΦϓγϣϯ
17 17 ngx_mruby ͕ొ͢Δ2ͭͷϙΠϯτ • ಈతϧʔςΟϯά • cookie ͷϑΟϧλϦϯά ΧϥʔϛʔWPΦϓγϣϯ
18 ಈతϧʔςΟϯά Section 5 18
19 ಈతϧʔςΟϯά 19 ͜ͷΜͷ͓ ઌఔͷਤͷ...
20 20 ՝ • γϣοϓʢͷυϝΠϯʣͱύεʹΑͬͯҟͳ ΔΞοϓετϦʔϜʹϓϩΩγ͢Δ • ΧϥʔϛʔWPΦϓγϣϯΛ͍ͬͯͳ͍ γϣοϓϓϩΩγ͠ͳ͍ʢ404ʣ ಈతϧʔςΟϯά
21 21 ΞϓϦετΞ API Λհͯ͠ΠϯετʔϧใΛ࡞ ಈతϧʔςΟϯά
22 22 WPΦϓγϣϯͷ Web ΞϓϦ API ͔ΒγϣοϓใΛऔಘ͠... ಈతϧʔςΟϯά
23 23 γϣοϓͷυϝΠϯͱඥ͍ͨ WordPress Λ࡞ ಈతϧʔςΟϯά
24 24 ngx_mruby ϙΠϯτ
25 25 app-proxy ্ͷ ngx_mruby υϝΠϯͱύε͔ΒϓϩΩγઌΛฦ͢ API ʹϦΫΤετ ಈతϧʔςΟϯά
26 26 ngx_mruby ʹΑΓϓϩΩγઌʹಈతʹΞοϓετϦʔϜΛઃఆ ಈతϧʔςΟϯά
27 27 ngx_mruby Ͱղܾʂ • ϦΫΤετͷॲཧதʹ http Ͱ API ʹϦΫΤε
τ • ϓϩΩγͷΞοϓετϦʔϜΛಈతʹมߋ ಈతϧʔςΟϯά
28 cookie ͷ ϑΟϧλϦϯά Section 6 28
29 cookie ͷϑΟϧλϦϯά 29 ͜ͷΜͷ͓ ઌఔͷਤͷ...
30 30 ՝ • ಉ͡υϝΠϯ্ʹγϣοϓͱ WordPress ͕ଘ ࡏ͢ΔͨΊɺγϣοϓͷ cookie Λ
WordPress ͔Βࢀরɺૢ࡞Ͱ͖ͯ͠·͏ • WordPress ͷͬऔΓѱҙͷ͋ΔϓϥάΠ ϯ͕ଘࡏ͢ΔͱʹͳΔ cookie ͷϑΟϧλϦϯά
31 31 ղܾͷΞϓϩʔν • Χϥʔϛʔγϣοϓͷ cookie ʹ໊લʹಛఆ ͷϓϨϑΟοΫΛ͚Δ • app-proxy
Ͱ্هʹ֘͢Δ໊લͷ cookie cookie ϔομ set-cookie ϔομͱʹϑΟ ϧλ͢Δ cookie ͷϑΟϧλϦϯά
32 32 ngx_mruby ϙΠϯτ
33 33 cookie ͷϑΟϧλϦϯά ΞʔΩςΫνϟ
34 34 • ΞϓϦέʔγϣϯαʔό ͷલ໘ʹஔͨ͠ ngx_mruby Ͱ cookie ໊ͷ ϓϨϑΟοΫεΛண
• Web ΞϓϦέʔγϣϯʹ खΛೖΕΔඞཁͳ͠ cookie ͷϑΟϧλϦϯά
35 35 • ϓϨϑΟοΫεͷ͍ͨ ໊લͷ cookie app- proxy ͰϑΟϧλ͠
WordPress ͞ͳ͍ • WordPress ͔Βҙਤతʹ ϓϨϑΟοΫεΛ͚ͭͨ ໊લͰ set-cookie ϔομ ͕ૹΒΕͯϒϩοΫ cookie ͷϑΟϧλϦϯά
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 ·ͱΊ Section 7 37
38 38 ·ͱΊ 2020ͷ ngx_mruby on Χϥʔϛʔγϣοϓ • ৽ͨʹ2ͭͷར༻ࣄྫΛհ ◦
ಈతϧʔςΟϯά ◦ cookie ϑΟϧλϦϯά • ࠓޙదࡐదॴͰ׆༻͍͖ͯ͠·͢ ngx_mruby ศརʂ