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
100
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
組織成長を加速させるオンボーディングの取り組み
sudoakiy
2
220
【Startup CTO of the Year 2024 / Audience Award】アセンド取締役CTO 丹羽健
niwatakeru
0
1.4k
AWS Lambda のトラブルシュートをしていて思うこと
kazzpapa3
2
190
飲食店データの分析事例とそれを支えるデータ基盤
kimujun
0
210
AIチャットボット開発への生成AI活用
ryomrt
0
170
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
160
日経電子版のStoreKit2フルリニューアル
shimastripe
1
150
DynamoDB でスロットリングが発生したとき_大盛りver/when_throttling_occurs_in_dynamodb_long
emiki
1
450
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
7
690
DynamoDB でスロットリングが発生したとき/when_throttling_occurs_in_dynamodb_short
emiki
0
270
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
3
640
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Navigating Team Friction
lara
183
14k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
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 ศརʂ