Slide 1

Slide 1 text

෱Ҫ྽ @fukuiretu 2019.06.12 OPUFFOHJOFFSNFFUVQ $MPVE'SPOU VTFDBTFT OPUFͷࣄྫ

Slide 2

Slide 2 text

ࣗݾ঺հ Engineer Full Remote Worker piece of cake, inc. ೖࣾ ੨৿ݝ߂લࢢࡏॅ 3VCZPO3BJMT /VYUKT "84 @r82 @fukuiretu @fukuiretu ෱Ҫ྽

Slide 3

Slide 3 text

ΞδΣϯμ OPUFͷΠϯϑϥߏ੒ $'Λར༻͢ΔϝϦοτʗσϝϦοτ 5JQT ·ͱΊ

Slide 4

Slide 4 text

ΞδΣϯμ OPUFͷΠϯϑϥߏ੒ $'Λར༻͢ΔϝϦοτʗσϝϦοτ 5JQT ·ͱΊ

Slide 5

Slide 5 text

OPUFͷΠϯϑϥߏ੒ $MPVE'SPOUͰ"OHVMBS /VYUΛ੾Γସ͑

Slide 6

Slide 6 text

ΞδΣϯμ OPUFͷΠϯϑϥߏ੒ $'Λར༻͢ΔϝϦοτʗσϝϦοτ 5JQT ·ͱΊ

Slide 7

Slide 7 text

$MPVE'SPOU $' ͱ͸ "84͕ఏڙ͢Δߴ଎ɾߴύϑΥʔϚϯεͳ ίϯςϯπ഑৴αʔϏε $%/ ΞηοτͷΩϟογϡ༻్Ҏ֎ʹ΋࢖͑Δʂ

Slide 8

Slide 8 text

ύεϕʔεͷϦόʔεϓϩΩγ ! $'Λར༻͢ΔϝϦοτ

Slide 9

Slide 9 text

Multi Origin &MBTUJD#FBOTUBML "1*(BUFXBZ "-# 4 etc… $'Λར༻͢ΔϝϦοτ

Slide 10

Slide 10 text

ύεຖʹΩϟογϡઃఆ͕Մೳ ElasticBeanstalk path /login /recommend ALB ͳ͠ ͳ͠ /aseets/images/* ࣌ؒ S3 origin cache $'Λར༻͢ΔϝϦοτ Cache Behavior

Slide 11

Slide 11 text

ҎԼͷϫΠϧυΧʔυͷΈར༻Մೳ ΋͘͠͸ͦΕҎ্ͷจࣈྻ จࣈ ॊೈͳਖ਼نදݱ͸࢖͑ͳ͍ͷͰ63-ઃܭ͸৻ॏʹʂ ύεύλʔϯͷ஫ҙ఺ ! $'Λར༻͢ΔϝϦοτ

Slide 12

Slide 12 text

$'Λར༻͢ΔϝϦοτ ηΩϡϦςΟରࡦ !

Slide 13

Slide 13 text

1$*%44ରԠ #05ରࡦ %%P4؇࿨ 944ରࡦ 42-Jରࡦ https://aws.amazon.com/jp/waf/ $'Λར༻͢ΔϝϦοτ "848"'ʢ΢ΣϒΞϓϦέʔγϣϯϑΝΠΞ΢Υʔϧʣ AWS WAF

Slide 14

Slide 14 text

ແྉͰ࢖͑Δʢ΋Εͳ͘෇͍ͯ͘Δʣ %%P4؇࿨ https://aws.amazon.com/jp/shield/ $'Λར༻͢ΔϝϦοτ "844IJFMEʢϚωʔδυܕͷ%%P4อޢʣ AWS Shield Standard

Slide 15

Slide 15 text

$'Λར༻͢ΔϝϦοτ "-#ͷલஈʹஔ͘͜ͱͰϨεϙϯε޲্ !

Slide 16

Slide 16 text

$'Λར༻͢ΔϝϦοτ Secured API Acceleration with Engineers from Amazon CloudFront and Slack https://www.slideshare.net/AmazonWebServices/secured-api-acceleration-with-engineers-from-amazon-cloudfront-and-slack 4MBDLࣾͷࣄྫ

Slide 17

Slide 17 text

$'Λར༻͢ΔϝϦοτ DSA %ZOBNJD4JUF"DDFMFSBUJPO Τοδϩέʔγϣϯ ΦϦδϯ ωοτϫʔΫ࠷దԽ ϨΠςϯγ͕௿͘ͳΔϨεϙϯε͕଎͘ͳΔ ˞ΤοδϩέʔγϣϯΦϦδϯؒͷڑ཭͕͍ۙ৔߹͸ޮՌ͕ബ͍

Slide 18

Slide 18 text

$'Λར༻͢ΔϝϦοτ ৄ͘͠͸ͦͷͬͭ͞Μͷϒϩάʹͯ $MPVE'SPOUΛ͔·͢ͱΩϟογϡͳ͠ͷ"1*ίʔϧͰ΋଎͘ͳΔΑ͏ͩ http://blog.livedoor.jp/sonots/archives/48002650.html

Slide 19

Slide 19 text

ίετ ·ͣ͸؆қݟੵπʔϧͰ͓ݟੵΓΛʂ Πϯλʔωοτ΁ͷσʔλసૹྔ )551ϝιουͷϦΫΤετ ΦϦδϯ΁ͷσʔλసૹྔ https://calculator.s3.amazonaws.com/index.html?lng=ja_JP FUDʜ $'Λར༻͢ΔσϝϦοτ

Slide 20

Slide 20 text

$MPVE'SPOU #FIBWJPS ϧʔςΟϯάͷࢄࡏԽ /VYUKT WVFSPVUFS "OHVMBS+4 VJSPVUFS 3VCZPO3BJMT SPVUFSSC New $'Λར༻͢ΔσϝϦοτ

Slide 21

Slide 21 text

ΞδΣϯμ OPUFͷΠϯϑϥߏ੒ $'Λར༻͢ΔϝϦοτʗσϝϦοτ 5JQT ·ͱΊ

Slide 22

Slide 22 text

5JQT ΫϥΠΞϯτ*1ͷऔಘ !

Slide 23

Slide 23 text

3BJMTͰ*1Λऔಘ͢Δϝιου 5JQT ActionDispatch::Request .remote_ip ActionDispatch::Request .ip 53645&%*1 ΞυϨεͷ֦ுੑ )551@$-*&/5@*1 ΛՃຯ ☓ ̋ ̋ ☓ "DUJPO%JTQBUDI3FRVFTUJQ ͸ Λར༻

Slide 24

Slide 24 text

5JQT ͷར༻έʔε 3BDLNJEESFXBSF (SBQF "QQMJDBUJPO$POUSPMMFS SFRVFTUJQͷ࣮ମ͸3BDL3FVRFTUJQ "DUJPO%JTQBUDI3FRVFTUJQΛར༻͢Δ͜ͱͰ౷Ұ 3BDL3FVRFTU (SBQF3FRVFTU "DUJPO%JTQBUDI3FRVFTU 3BDLNJEESFXBSF

Slide 25

Slide 25 text

$MPVE'SPOUͷ*1͕औΕΔ $'ͷ*1֎෦*1ͱͯ͠൑அ 5JQT ݪҼ ൃੜͨ͠໰୊

Slide 26

Slide 26 text

5JQT 3BDL3FVRFTUʹϞϯΩʔύον $'ͷ*1ϨϯδΛ53645&%*1ΞυϨεʹ௥Ճ ରॲ

Slide 27

Slide 27 text

ΛΦʔόʔϥΠυ ͠ɺˢͰੜ੒ͨ͠ 53645&%ͳ*1܈ Λར༻ trusted_proxy? $MBTTϩʔυ࣌ʹ $'ͷ*1ϨϯδΛ ੜ੒͢Δ ˢͰੜ੒ͨ͠$'ͷ *1ϨϯδΛؚΊɺ MPDBMܥ΍JOUBSOBM ܥͷ*1Λ߹Θͤͯ ఆٛ 5JQT

Slide 28

Slide 28 text

3BDL3FRVFTUJQ $MPVE'SPOUͷ*1ΞυϨεൣғ 3BDL3FRVFTUJQ $MPVE'SPOUͷ*1ΞυϨεൣғ ࢀߟࢿྉ https://github.com/rack/rack/blob/master/lib/rack/ request.rb#L267-L277 https://docs.aws.amazon.com/ja_jp/AmazonCloudFront/latest/ DeveloperGuide/LocationsOfEdgeServers.html 5JQT

Slide 29

Slide 29 text

5JQT ϝϯςφϯεϖʔδͷදࣔ !

Slide 30

Slide 30 text

Ϟνϕʔγϣϯ ιʔϦʔαʔόʔͷ༻ҙ΋໘౗ /HJOYͷDPOpHมߋ͸໘౗ -BNCEB!&EHFͰ୅ସ 5JQT

Slide 31

Slide 31 text

-BNCEB!&EHFͱ͸ ᶃViewer Request ᶄ0SJHJO Request ᶅ0SJHJO Response ᶆ7JFXFS Response Ϣʔβʔ $' ΦϦδϯ $MPVE'SPOU্ͰҎԼͷ͍ͣΕ͔ͷΠϕϯτΛ ϑοΫͯ͠-BNCEBΛ࣮ߦ͢ΔαʔϏε 5JQT

Slide 32

Slide 32 text

ΞΫηεڐՄ*1΍ϝϯςφ ϯε։࢝࣌ؒͳͲಈతʹม ߋ͍ͨ͠஋͸4ʹKTPOͱ ͯ͠഑ஔ͠ಡΈࠐΈ εςʔλεͰɺ ೚ҙͷ)5.-#PEZΛฦ͢ ʢ7JFXFS3FRVFTUʹઃఆʣ 5JQT

Slide 33

Slide 33 text

-BNCEBಉ༷ʹεϩοτϦϯά͕ൃੜ 5JQT ؀ڥม਺ͷར༻ෆՄ ಈ࡞ͨ͠ΤοδϩέʔγϣϯʹΑͬͯϩά ग़ྗ͞ΕΔϦʔδϣϯ͕ܾ·Δ όʔδχΞϦʔδϣϯʹ഑ஔ -BNCEB!&EHFͷ஫ҙ఺

Slide 34

Slide 34 text

ࢀߟࢿྉ 5JQT "84-BNCEB!&EHFͷϩά͸Ͳ͜ʁ $MPVE'SPOU-BNCEB!&EHFͰͷ"84 -BNCEBͷ࢖༻ https://dev.classmethod.jp/cloud/aws/where-is-the-lambda- edge-log/ https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/lambda-edge.html

Slide 35

Slide 35 text

ΞδΣϯμ OPUFͷΠϯϑϥߏ੒ $'Λར༻͢ΔϝϦοτʗσϝϦοτ 5JQT ·ͱΊ

Slide 36

Slide 36 text

·ͱΊ ΫϥΠΞϯτ*1ΛऔΓ͍ͨͱ͖͸ཁ஫ҙ $'ʹݶΒͣϓϩΩγΛհͯ͠ଟஈʹͳΔ৔߹ -BNCEB!&EHFศར ίετ໰୊͕ΫϦΞͰ͖ΔͳΒಋೖ͢΂͖ ੒໿͕ଟ͍ͷͰτϨʔυΦϑΛԡ͑Δ

Slide 37

Slide 37 text

͋Γ͕ͱ͏͍͟͝·ͨ͠