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
930
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.7k
Other Decks in Technology
See All in Technology
20241120_JAWS_東京_ランチタイムLT#17_AWS認定全冠の先へ
tsumita
2
280
EventHub Startup CTO of the year 2024 ピッチ資料
eventhub
0
120
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
220
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
28
13k
なぜ今 AI Agent なのか _近藤憲児
kenjikondobai
4
1.4k
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
390
TypeScriptの次なる大進化なるか!? 条件型を返り値とする関数の型推論
uhyo
2
1.7k
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
490
個人でもIAM Identity Centerを使おう!(アクセス管理編)
ryder472
3
220
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
1k
組織成長を加速させるオンボーディングの取り組み
sudoakiy
2
170
RubyのWebアプリケーションを50倍速くする方法 / How to Make a Ruby Web Application 50 Times Faster
hogelog
3
940
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Adopting Sorbet at Scale
ufuk
73
9.1k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Music & Morning Musume
bryan
46
6.2k
Thoughts on Productivity
jonyablonski
67
4.3k
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 ΤϯδχΞืूͯ͠·͢ʂ