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
kargoの魅力について伝える
magisystem0408
0
210
20241214_WACATE2024冬_テスト設計技法をチョット俯瞰してみよう
kzsuzuki
3
450
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
160
re:Invent をおうちで楽しんでみた ~CloudWatch のオブザーバビリティ機能がスゴい!/ Enjoyed AWS re:Invent from Home and CloudWatch Observability Feature is Amazing!
yuj1osm
0
120
GitHub Copilot のテクニック集/GitHub Copilot Techniques
rayuron
36
13k
OpenAIの蒸留機能(Model Distillation)を使用して運用中のLLMのコストを削減する取り組み
pharma_x_tech
4
560
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
8
7.3k
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
180
2024年にチャレンジしたことを振り返るぞ
mitchan
0
140
Jetpack Composeで始めるServer Cache State
ogaclejapan
2
170
Oracle Cloudの生成AIサービスって実際どこまで使えるの? エンジニア目線で試してみた
minorun365
PRO
4
280
Opcodeを読んでいたら何故かphp-srcを読んでいた話
murashotaro
0
230
Featured
See All Featured
Gamification - CAS2011
davidbonilla
80
5.1k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Statistics for Hackers
jakevdp
796
220k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
Building Your Own Lightsaber
phodgson
103
6.1k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
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 ΤϯδχΞืूͯ͠·͢ʂ