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
【技術書典17】OpenFOAM(自宅で極める流体解析)2次元円柱まわりの流れ
kamakiri1225
0
210
AWSコンテナ本出版から3年経った今、もし改めて執筆し直すなら / If I revise our container book
iselegant
15
4k
CyberAgent 生成AI Deep Dive with Amazon Web Services / genai-aws
cyberagentdevelopers
PRO
1
480
顧客が本当に必要だったもの - パフォーマンス改善編 / Make what is needed
soudai
24
6.8k
日経電子版におけるリアルタイムレコメンドシステム開発の事例紹介/nikkei-realtime-recommender-system
yng87
1
500
事業者間調整の行間を読む 調整の具体事例
sugiim
0
1.5k
신뢰할 수 있는 AI 검색 엔진을 만들기 위한 Liner의 여정
huffon
0
350
グローバル展開を見据えたサービスにおける機械翻訳プラクティス / dp-ai-translating
cyberagentdevelopers
PRO
1
150
よくわからんサービスについての問い合わせが来たときの強い味方 Amazon Q について
kazzpapa3
0
220
サイバーエージェントにおける生成AIのリスキリング施策の取り組み / cyber-ai-reskilling
cyberagentdevelopers
PRO
2
200
「最高のチューニング」をしないために / hack@delta 24.10
fujiwara3
21
3.4k
分布で見る効果検証入門 / ai-distributional-effect
cyberagentdevelopers
PRO
4
700
Featured
See All Featured
Statistics for Hackers
jakevdp
796
220k
The Art of Programming - Codeland 2020
erikaheidi
51
13k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
9
680
GitHub's CSS Performance
jonrohan
1030
460k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
14
1.9k
Teambox: Starting and Learning
jrom
132
8.7k
Intergalactic Javascript Robots from Outer Space
tanoku
268
27k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
A Tale of Four Properties
chriscoyier
156
23k
Fontdeck: Realign not Redesign
paulrobertlloyd
81
5.2k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
664
120k
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 ศརʂ