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
making-nginx-practical-guide
Search
Tatsuhiko Kubo
February 08, 2016
Technology
6
9.5k
making-nginx-practical-guide
Tatsuhiko Kubo
February 08, 2016
Tweet
Share
More Decks by Tatsuhiko Kubo
See All by Tatsuhiko Kubo
Handling a tremendous amount of images with Fastly / Yamagoya Traverse 2020
cubicdaiya
2
1.4k
System Integration with Fastly
cubicdaiya
0
570
実例で学ぶ画像最適化集 with ImageFlux / ImageFlux meetup#2
cubicdaiya
4
19k
Software Engineer, Infrastructure
cubicdaiya
4
3.1k
High Performance Count Up!
cubicdaiya
0
330
ImageFluxを利用した画像配信の最適化 / ImageFlux meetup 201801
cubicdaiya
0
2.9k
Building high performance push notification server in Go
cubicdaiya
5
3.2k
メルカリのデータ分析基盤 / mercari data analysis infrastructure
cubicdaiya
11
12k
On-call Engineering
cubicdaiya
8
6.5k
Other Decks in Technology
See All in Technology
アップデート紹介:AWS Data Transfer Terminal
stknohg
PRO
0
170
AWS re:Invent 2024 ふりかえり
kongmingstrap
0
130
統計データで2024年の クラウド・インフラ動向を眺める
ysknsid25
2
840
サービスでLLMを採用したばっかりに振り回され続けたこの一年のあれやこれや
segavvy
2
370
Amazon SageMaker Unified Studio(Preview)、Lakehouse と Amazon S3 Tables
ishikawa_satoru
0
150
Turing × atmaCup #18 - 1st Place Solution
hakubishin3
0
470
WACATE2024冬セッション資料(ユーザビリティ)
scarletplover
0
190
サーバレスアプリ開発者向けアップデートをキャッチアップしてきた #AWSreInvent #regrowth_fuk
drumnistnakano
0
190
Wantedly での Datadog 活用事例
bgpat
1
410
生成AIをより賢く エンジニアのための RAG入門 - Oracle AI Jam Session #20
kutsushitaneko
4
210
祝!Iceberg祭開幕!re:Invent 2024データレイク関連アップデート10分総ざらい
kniino
2
250
UI State設計とテスト方針
rmakiyama
2
320
Featured
See All Featured
Optimizing for Happiness
mojombo
376
70k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Testing 201, or: Great Expectations
jmmastey
40
7.1k
Documentation Writing (for coders)
carmenintech
66
4.5k
Why Our Code Smells
bkeepers
PRO
335
57k
Thoughts on Productivity
jonyablonski
67
4.4k
Designing Experiences People Love
moore
138
23k
A designer walks into a library…
pauljervisheath
204
24k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Typedesign – Prime Four
hannesfritz
40
2.4k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
Transcript
nginx࣮ફೖ ϝΠΩϯά Tatsuhiko Kubo@cubicdaiya nginx Tech Talks 2016/02/08
@cubicdaiya / Tatsuhiko Kubo Principal Engineer, SRE @ Mercari, Inc.
ngx_small_light, ngx_dynamic_upstream, nginx-build, slackboard,cachectl, gaurun, etc…
None
https://www.mercari.com/ Mercari - Your Friendly Mobile Marketplace
Agenda • ʰnginx࣮ફೖʱͷհ • ࣥචʹ·ͭΘΔΤϐιʔυ • ຊॻ੶ʹܝࡌ͖͠Εͳ͔ͬͨ༰ɺɹɹɹ nginxͷ৽ػೳʹ͍ͭͯ
None
ʰnginx࣮ફೖʱষߏ • 1ষ nginxͷ֓ཁͱΞʔΩςΫνϟ • 2ষ Πϯετʔϧͱىಈ • 3ষ جຊઃఆ
• 4ষ ੩తͳWebαΠτͷߏங • 5ষ ҆શ͔ͭߴͳHTTPSαʔόͷߏங
ʰnginx࣮ફೖʱষߏ • 6ষ WebΞϓϦέʔγϣϯαʔόͷߏங • 7ষ େنίϯςϯπ৴αʔόͷߏங • 8ষ Webαʔόͷӡ༻ͱϝτϦΫεϞχλϦϯά
• 9ষ LuaʹΑΔnginxͷ֦ு • 10ষ OpenResty
ࣥච։࢝ɿ201311݄ ࣥචྃɿ201512݄ ൃചɹɿ20161݄ 2͔͔Γ·ͨ͠…
ষߏ ݪҊʢ2013ࠒʣ • 1ষ nginxͷ֓ཁͱΞʔΩςΫνϟ • 2ষ Πϯετʔϧ • 3ষ
جຊઃఆ • 4ষ ੩తͳWebαΠτͷߏங • 5ষ WebΞϓϦέʔγϣϯαʔόͷߏங
ষߏ ݪҊʢ2013ࠒʣ • 6ষ େنίϯςϯπ৴αʔόͷߏங • 7ষ ը૾ετϨʔδαʔόͷߏங • 8ষ
nginxαʔόͷӡ༻ʗࢹ • 9ষ ϋΠύϑΥʔϚϯεnginx • 10ষ LuaʹΑΔnginxͷ֦ு • 11ষ ֦ுϞδϡʔϧͷ࡞Γํ
Ϙπʹͳͬͨষ
ը૾ετϨʔδαʔόͷߏங
ʮը૾ετϨʔδαʔόͷߏஙʯͳΜͰ͚͢Ͳɺ ͜ΕྲྀΕతʹʮେنίϯςϯπ৴αʔόʯͷষʹ ౷߹͠·͢Ͷ ͑ɺ͋ɺ͏Μ ※ձͷ༰ΠϝʔδͰ͢
ը૾ετϨʔδαʔόͷߏங • nginxͰαϜωΠϧੜػೳ͖ετϨʔδαʔόΛߏங͢Δ ͩͬͨ • ngx_http_image_filter_module • ngx_http_dav_module • େنίϯςϯπ৴αʔόͷষʹ౷߹ͨ͠ํ͕͍͍ͷͰ
ʁ by @harukasan • ༰͝ͱ7ষʹ౷߹͞Ε·ͨ͠ • ࠓͳΒngx_small_lightͷΛͯ͠Α͔͔ͬͨ͠Εͳ͍
ϋΠύϑΥʔϚϯεnginx
ϋΠύϑΥʔϚϯεnginx • tcp_nopushΞοϓετϦʔϜͷΩʔϓΞ ϥΠϒnginxͰͷνϡʔχϯάू • ֤ষ͕༻్ຖʹղઆ͍ͯ͠Δ͜ͱ͋ͬͯ͜ ͚ͩ͜·ͱ·Γ͕ͳ͍ • harukasanͷఏҊͰదͳষʹࢄ
ʮϋΠύϑΥʔϚϯεnginxʯͳΜͰ͚͢Ͳɺ ͜Ε֤߲ͷͷ༰͕όϥόϥͳͷͰ ผʑͷষʹࢄͤ͞·͢Ͷɻ ͓ɺ͓͏ ※ձͷ༰ΠϝʔδͰ͢
֦ுϞδϡʔϧͷ࡞Γํ • ్த·Ͱॻ͍ͯ·͕ͨ͠ɺશવϖʔδΓͳ͘ ͯΊ·ͨ͠ • ͜ͷ༰͚ͩͰຊ͕Ұॻ͚Δ • ༰͕શવೖ͡Όͳ͍ • CΑΓLuaͷղઆ૿ͨ͠ํ͕ಡऀͷͨΊʹͳΔ
• ͦ͏ͩɺOpenRestyʹ͠Α͏ʂ
ޙͰՃ͞Εͨষ
҆શ͔ͭߴͳHTTPSαʔόͷߏங
҆શ͔ͭߴͳHTTPSαʔόͷߏங • ॳʰ੩తͳWebαΠτͷߏஙʱͰશ෦ղઆ ͍ͯͨ͠ • ͔͠͠ɺHTTPSͷॏཁੑͷߴ·Γ2014ࠒ͔ Βͷ૬͙࣍OpenSSLͷ੬ऑੑใࠂ͔Β༰͕ ංେԽ • e.g.
HeartBleed, FREAK Attack… • ݁Ռɺؙʑ1ষׂ͍ͯղઆ͢Δ͜ͱʹ
OpenResty
OpenResty • CʹΑΔ֦ுϞδϡʔϧ࡞ͷষΛͬͨͷͰ ͔ΘΓʹೖΕͨ • ngx_luaؚΊଟࠃͰॳͷຊ֨తͳղઆ • ngx_luaΛར༻͢Δ߹ɺʹར༻͢ΔΑΓ OpenRestyʹ͓ͯ͘͠ํָ͕ͳ͜ͱ͕ଟ͍ͷ ͰΦεεϝͰ͢
ʰnginx࣮ફೖʱষߏ • 1ষ nginxͷ֓ཁͱΞʔΩςΫνϟ • 2ষ Πϯετʔϧͱىಈ • 3ষ جຊઃఆ
• 4ষ ੩తͳWebαΠτͷߏங • 5ষ ҆શ͔ͭߴͳHTTPSαʔόͷߏங
ʰnginx࣮ફೖʱষߏ • 6ষ WebΞϓϦέʔγϣϯαʔόͷߏங • 7ষ େنίϯςϯπ৴αʔόͷߏங • 8ষ Webαʔόͷӡ༻ͱϝτϦΫεϞχλϦϯά
• 9ষ LuaʹΑΔnginxͷ֦ு • 10ষ OpenResty
೦ߍ࣌ظͷΈ(2015ळʙౙ)
nginxͷHTTP/2࣮͕ ͍ͭग़Δ͔Θ͔Βͳ͍
nginxͷdynamic module͕ ͍ͭग़Δ͔Θ͔Βͳ͍
nginx࣮ફೖͰղઆͯ͠ͳ͍ओͳ༰ • ngx_mail_xxx_module • nginxͰϝʔϧϓϩΩγ • ngx_stream_xxx_module • nginxͰL4ϩʔυόϥϯε •
ngx_luaͷ࠷৽ͷσΟϨΫςΟϒ • e.g. (ssl_certificate|balancer)_by_lua_block
nginxͰL4ϩʔυόϥϯε stream { upstream app { server x.x.x.x:12345; server x.x.x.y:12345;
} server { listen 50000; proxy_pass app; } }
xxx_by_lua_block (e.g. content_by_lua_block) • LuaεΫϦϓτΛΠϯϥΠϯͰॻ͘ࡍʹώΞυ ΩϡϝϯτͰॻ͚ΔΑ͏ʹͳͬͨ
content_by_lua location / { content_by_lua ‘ngx.say(‘hello’)’; } Syntax error…
content_by_lua_block location / { content_by_lua_block { ngx.say(‘hello’) } }
ssl_certificate_by_lua_(block|file) • TLSϋϯυγΣΠΫ࣌ʹLuaεΫϦϓτΛϑο ΫͰ͖Δ • ূ໌ॻͷಈతͳΓସ͑ʹԠ༻Մೳ
balancer_by_lua_(block|file) • upstreamίϯςΩετͰར༻ग़དྷΔσΟϨΫ ςΟϒ • ಈతͳϩʔυόϥϯαʔͷߏஙʹར༻Մೳ
ngx_stream_lua_module • https://github.com/openresty/stream-lua- nginx-module • ngx_luaͰL4ϩʔυόϥϯε • Status • Quite
usable but still experimental.
Coming soon… • dynamic module support of nginx • طʹnginxͷmainlineϦϙδτϦʹίϛοτ͞
ΕͯΔͷͰଟ࣍ͷ1.9.11ͰདྷΔ ./configure —with-stream=dynamic ▪ streamϞδϡʔϧͷಈతϩʔσΟϯά ▪ nginx.confͷઃఆ load_module /path/to/ngx_stream_module.so