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
NginxとELBの罠
Search
innossh
November 25, 2017
Technology
1
880
NginxとELBの罠
WEBエンジニア勉強会 #04
https://web-engineer-meetup.connpass.com/event/70551/
innossh
November 25, 2017
Tweet
Share
More Decks by innossh
See All by innossh
AnsibleとAWXでレガシーな本番環境デプロイを1-Click実行 / LT - Ansible Night in Tokyo 201712
innossh
1
1.6k
Other Decks in Technology
See All in Technology
KubeConにproposalを送りたい人へのアドバイス
sat
PRO
3
250
web-application-security
matsuihidetoshi
0
170
私が trocco を推す理由
__allllllllez__
1
230
複雑な構成要素を持つUIとの向き合い方 〜新・支出グラフでの実例〜 / B43 TECH TALK
nakamuuu
0
140
GrafanaMeetup_AmazonManagedGrafanaのアクセス制御機能とマルチテナント環境下でのアクセス制御について
daitak
0
240
[新卒向け研修資料] テスト文字列に「うんこ」と入れるな(2024年版)
infiniteloop_inc
4
15k
Kernel MemoryでAzure OpenAI Serviceとお手軽データソース連携
mitsuzono
1
250
MySQL の SQL クエリチューニングの要所を掴む勉強会
andpad
3
6.4k
Reducing Cross-Zone Egress at Spotify with Custom gRPC Load Balancing Recap
koh_naga
0
210
本当のAWS基礎
toru_kubota
0
520
AOAI をきっかけに 社内の Azure 管理を見直した話
recruitengineers
PRO
1
290
生産性向上チームの紹介
cybozuinsideout
PRO
1
870
Featured
See All Featured
Producing Creativity
orderedlist
PRO
337
39k
Principles of Awesome APIs and How to Build Them.
keavy
121
16k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
30
6k
Ruby is Unlike a Banana
tanoku
96
10k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
2
1.3k
Scaling GitHub
holman
457
140k
Build your cross-platform service in a week with App Engine
jlugia
225
17k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
17
1.4k
How STYLIGHT went responsive
nonsquared
92
4.8k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
6
1.5k
What’s in a name? Adding method to the madness
productmarketing
PRO
16
2.6k
Writing Fast Ruby
sferik
621
60k
Transcript
/HJOYͱ&-#ͷ᠘
ࣗݾհ !JOOPTTI ,JJגࣜձࣾ*P5ΫϥυϓϥοτϑΥʔϜ ιϑτΣΞΤϯδχΞ %FW0QT +BWB "OTJCMF ࠷ۙ"MFYB εϓϥτΡʔϯ
ొ͢Δͷ w/HJOY w0QFO3FTUZ w7BSOJTI w&-#
/HJOYͷઃఆ᠘͕ଟ͍
/HJOYࡾΫΠζ
ϨεϙϯεϔομͲ͏ͳΔʁ location /if { set $true 1; if ($true)
{ add_header X-First 1; } if ($true) { add_header X-Second 2; } return 204; }
"9'JSTUͱ94FDPOE#9'JSTUͷΈ $94FDPOEͷΈ location /if { set $true 1; if
($true) { add_header X-First 1; } if ($true) { add_header X-Second 2; } return 204; }
͑$94FDPOEͷΈ location /if { set $true 1; if ($true)
{ add_header X-First 1; } if ($true) { add_header X-Second 2; } return 204; }
*G*T&WJM ཧ༝ͳ͍
Ͱ͏Ұ
ϦΫΤετϔομͲ͏ͳΔʁ http { proxy_set_header X-Foo foo; server { proxy_set_header
X-Bar bar; location /proxysetheader { proxy_pass http://localhost:8080; proxy_set_header X-Baz baz; } } }
"9'PPͱ9#BSͱ9#B[ #9#BSͱ9#B[$9#B[ͷΈ http { proxy_set_header X-Foo foo; server {
proxy_set_header X-Bar bar; location /proxysetheader { proxy_pass http://localhost:8080; proxy_set_header X-Baz baz; } } }
͑$9#B[ͷΈ http { proxy_set_header X-Foo foo; server { proxy_set_header
X-Bar bar; location /proxysetheader { proxy_pass http://localhost:8080; proxy_set_header X-Baz baz; } } }
ཧ༝͋Δ
QSPYZ@TFU@IFBEFS ಉ͡Ϩϕϧʹఆ͕ٛͳ͍࣌ʹ લͷϨϕϧͷఆٛΛҾ͖ܧ͙
http { proxy_set_header X-Foo foo; server { proxy_set_header X-Bar
bar; location /proxysetheader { proxy_pass http://localhost:8080; proxy_set_header X-Foo foo; proxy_set_header X-Bar bar; proxy_set_header X-Baz baz; } } }
˞ͩͨ͠ϨΞέʔεͳͷͰ ϦϥοΫεͯ͠ௌ͍͍ͯͩ͘͞ ͔͜͜Β͕ຊ
લஔ͖ w7BSOJTIΛ0QFO3FTUZʹஔ͖͑Δ࡞ۀ ͰϋϚͬͨ᠘ w)551ϔομ w$POUFOU-FOHUI w5SBOTGFS&ODPEJOHDIVOLFE
Ή͔͠Ή͔͋͠Δͱ͜Ζʹ 7BSOJTIͱ0QFO3FTUZ ͕͍·ͨ͠
7BSOJTI 0QFO3FTUZ &-#
7BSOJTI$POUFOU-FOHUIΛ HTTP/1.1 200 OK Server: varnish Date: Tue, 22 Aug
2017 10:44:59 GMT Content-Type: application/json; charset=utf-8 Connection: keep-alive Status: 200 OK Content-Length: 20 Cache-Control: max-age=0, no-cache, no-store
0QFO3FTUZUSBOTGFSFODPEJOHΛ HTTP/1.1 200 OK Server: openresty Date: Tue, 22 Aug
2017 10:44:59 GMT Content-Type: application/json; charset=utf-8 Connection: keep-alive Status: 200 OK transfer-encoding: chunked Cache-Control: max-age=0, no-cache, no-store
όοΫΤϯυ +BWB ಉҰ 7BSOJTI 0QFO3FTUZ - Content-Length: 20 + transfer-encoding:
chunked
ͲΜͿΒ͜ʙͲΜͿΒ͜ʙ όοΫΤϯυಉҰͳͷʹ ࠩҟͷ͋ΔϨεϙϯε͕ ྲྀΕ͖ͯ·ͨ͠
w0QFO3FTUZͷஔ͖͑ޙɺϨεϙϯε͕ νϟϯΫԽ͞ΕΔ w)551Λ໊ΓͭͭɺνϟϯΫԽ͞Εͨ ϨεϙϯεΛѻ͑ͳ͍ΫϥΠΞϯτ͕ଘࡏ
َୀ࣏ νϟϯΫԽ͞ΕͨݪҼΛ ୀ࣏͠Α͏
όοΫΤϯυʹ HTTP/1.1 200 OK Date: Tue, 22 Aug 2017 10:44:59
GMT Content-Type: application/json; charset=utf-8 Connection: close Content-Length: 20 ↑Content-Length͍͍ͯͳ͍ Status: 200 OK Cache-Control: max-age=0, no-cache, no-store
$POUFOU-FOHUIෆཁʁ wແ͍߹ίωΫγϣϯΛΫϩʔζ͢Δ·Ͱ ϝοηʔδΛड৴ w7BSOJTI$POUFOU-FOHUIΛউखʹ͚ ͍ͯͨ
ͦΕͳΒ0QFO3FTUZʹ HTTP/1.1 200 OK Server: openresty Date: Tue, 22 Aug
2017 10:44:59 GMT Content-Type: application/json; charset=utf-8 Connection: keep-alive Status: 200 OK Transfer-Encoding: chunked Cache-Control: max-age=0, no-cache, no-store
DIVOLFE@USBOTGFS@FODPEJOH w/HJOYͷઃఆ DIVOLFE@USBOTGFS@FODPEJOHσϑΥ ϧτͰPO w0QFO3FTUZ$POUFOU-FOHUIͷແ͍Ϩ εϙϯεΛνϟϯΫԽ͢Δ
7BSOJTI0QFO3FTUZՈདྷʹ νϟϯΫԽ͞ΕͨݪҼΛ ಥ͖ࢭΊͨʜʁ
DIVOLFE@USBOTGFS@FODPEJOHΛPGGʹ HTTP/1.1 200 OK Server: openresty Date: Tue, 22 Aug
2017 10:44:59 GMT Content-Type: application/json; charset=utf-8 Connection: keep-alive Status: 200 OK transfer-encoding: chunked Cache-Control: max-age=0, no-cache, no-store
Ͳ͏ͤ/HJOYͷ᠘ͩΖ͏ʜ wDIVOLFE@USBOTGFS@FODPEJOHPGG͕ޮ ͔ͳ͍ wͲ͏ߟ͑ͯνϟϯΫԽ͢Δίʔυ͕࣮ߦ͞ ΕΔ͕ͣͳ͍ w࠶ϏϧυόʔδϣϯΞοϓޮՌͳ͠
ʁ /HJOYͷιʔείʔυΛಡΜͰ Ұ͚ͭͩؾ͍ͮͨ͜ͱ͕ʜ
None
HTTP/1.1 200 OK Server: openresty Date: Tue, 22 Aug 2017
10:44:59 GMT Content-Type: application/json; charset=utf-8 Connection: keep-alive Status: 200 OK transfer-encoding: chunked Cache-Control: max-age=0, no-cache, no-store
NginxͰ Transfer-Encoding: chunked
ΫϥΠΞϯτͰ transfer-encoding: chunked
ELBͰ transfer-encoding: chunked ʊਓਓਓਓਓਓʊ ʼɹಥવͷ&-#ɹʻ ʉ:?:?:?:?:ʉ
ݪҼ&-# w&-#$POUFOU-FOHUIͷແ͍Ϩεϙϯε ΛνϟϯΫԽ͢Δ wখจࣈͷUSBOTGFSFODPEJOHΛ͚Δ
ಉ྅ʮ"-#ͬͯΈͨΒʁʯ
"-#ΛͬͯΈΔͱ wಉ༷ʹϨεϙϯεΛνϟϯΫԽ͢Δ wେจࣈͷ5SBOTGFS&ODPEJOHΛ͚Δ͆ Nginx: Transfer-Encoding ELB: transfer-encoding ALB: Transfer-Encoding <=
վળʁ͆
ղܾࡦ w&-#ͷ5$1ϦεφΛ͏ w͘͠/-#Λ͏
·ͱΊ wେจࣈখจࣈʹཱͭ͆ w)551ඇରԠͷΫϥΠΞϯτͭΒ͍ w)551ϔομΛकΔʹ5$1ϩʔυόϥϯα Λ͏
Ҏ্ɺ/HJOYͱ&-#ͷ᠘ͷ *P5ΫϥυϓϥοτϑΥʔϜ,JJ LJJDPN ΤϯδχΞืूͯ͠·͢ʂ