æè¡2課ã®æ¾ç°ã§ããããã«ã¡ã¯ã
ALBããªãªã¸ã³ã¨ãã¦æå®ããAmazon CloudFrontã§ãã¯ã©ã¤ã¢ã³ãï½CloudFrontéã¨CloudFrontï½ALBéã®ä¸¡æ¹ã§ã«ã¹ã¿ã ãã¡ã¤ã³ã®è¨¼ææ¸ãç¨ãã¦æå·åããæ¹æ³ãã¾ã¨ãã¾ããã
- ä»åã®æ§æ
- æ§ç¯æé
- ã¾ã¨ã
- åèè¨äº
ä»åã®æ§æ
ä»åã®æ§æã¯ä»¥ä¸ã«ãªãã¾ãã
CloudFrontâALBâEC2ï¼Apacheï¼ã¨ããæ§æã§ãALBã¨CloudFrontã«ããããACMã§çºè¡ãã証ææ¸ãã¤ã³ã¹ãã¼ã«ãã¾ããããã«ãã£ã¦ã¯ã©ã¤ã¢ã³ãï½CloudFrontéã¨ãCloudFrontï½ALBéã§HTTPSéä¿¡ãå¯è½ã«ãªãã¾ãã
Route 53ã¯ãCloudFrontã«è¨å®ãããã¡ã¤ã³åï¼å³ä¸ã®example.com
ï¼ããã¹ãããããã«ä½¿ç¨ãã¾ãã
ãªããã®æ§æã§ã¯ãALBï½EC2éã¯HTTPéä¿¡ã«ãªãã¾ããä»åã¯è§¦ãã¾ããããHTTPSéä¿¡ã使ç¨ããå ´åã¯EC2ã«è¨¼ææ¸ãã¤ã³ã¹ãã¼ã«ããå¿ è¦ãããã¾ãã
æ§ç¯æé
æ¬è¨äºã®ä¸»é¡ã¯ã«ã¹ã¿ã ãã¡ã¤ã³ã使ç¨ããéä¿¡ã®æå·åã§ãã®ã§ãEC2ãALBãCloudFrontã®æ§ç¯ãå®äºãã¦ããç¶æ ãåæã¨ãã¦ããã¾ãã
â»ä»¥ä¸ã®ç¶æ ããã¹ã¿ã¼ããã¾ãã
ãªãæ¬è¨äºã§æ§ç¯ãããªã½ã¼ã¹ã®ä½æã»è¨å®æé ã®è©³ç´°ã«ã¤ãã¦ã¯ãæ«å°¾ã®ãåèè¨äºãã«å ¬å¼ããã¥ã¡ã³ãã®ãªã³ã¯ãè¨è¼ãã¦ããã¾ãã®ã§ãã¡ãããåç §ãã ããã
ï¼ï¼ãã¹ãã¾ã¼ã³ã®ä½æ
ã«ã¹ã¿ã ãã¡ã¤ã³ã使ç¨ãããã¹ãã¾ã¼ã³ãRoute 53ã«ä½æãã¾ãã
ãªãã«ã¹ã¿ã ãã¡ã¤ã³ã®åå¾ã«ã¯ãä»åã¯Freenomã¨ãããµã¼ãã¹ã使ç¨ãã¾ããã
âã§åå¾ãããã¡ã¤ã³åã§ãRoute 53ã§ãããªãã¯ãã¹ãã¾ã¼ã³ãä½æãã¾ãããªãæ¬è¨äºã§ã¯ãexample.com
ãã«ã¹ã¿ã ãã¡ã¤ã³åã¨ãã¦è©±ãé²ãã¾ãã
ãã¹ãã¾ã¼ã³ä½æå¾ãæãåºãããNSã¬ã³ã¼ãã®ValueããFreenomå´ã§NameServerã¨ãã¦è¨å®ãã¾ãã
ãã¹ãã¾ã¼ã³ã®ä½æã¯ä¸æ¦ä»¥ä¸ã§ãã
ï¼ï¼ACMã§è¨¼ææ¸ãçºè¡
ACMã§ãããªãã¯è¨¼ææ¸ãçºè¡ãã¾ãã
ALBã®è¨¼ææ¸ãçºè¡
ã¾ãã¯ALBã®è¨¼ææ¸ãçºè¡ãã¾ããä»åã¯ALBãæ±äº¬ãªã¼ã¸ã§ã³ã§ä½æãã¦ããããã証ææ¸ãæ±äº¬ãªã¼ã¸ã§ã³ã§çºè¡ãã¾ãã
ãã¡ã¤ã³åã«ã¯example.com
ã¨*.example.com
ãæå®ãã¾ããæ¤è¨¼æ¹æ³ã¯ãä»åã¯DNSãµã¼ãã¼ã¨ãã¦Route 53ã使ç¨ãã¦ããããDNS validation
ãæå®ãã¾ãã
ãªã¯ã¨ã¹ãå¾ãDNSæ¤è¨¼ãè¡ãã¾ãã証ææ¸ã®è©³ç´°ç»é¢ã§Create records in route 53
ãã¯ãªãã¯ããã¨ãç°¡åã«CNAMEã¬ã³ã¼ããç»é²ãããã¨ãå¯è½ã§ãã
以ä¸ã§ALBç¨è¨¼ææ¸ã®çºè¡ã¯å®äºã§ãã
CloudFrontã®è¨¼ææ¸ãçºè¡
ç¶ãã¦CloudFrontã®è¨¼ææ¸ãçºè¡ãã¾ãããªãCloudFrontã§ACMã®è¨¼ææ¸ã使ç¨ããå ´åã証ææ¸ã¯åé¨ãã¼ã¸ãã¢ãªã¼ã¸ã§ã³ã§çºè¡ããå¿ è¦ãããã¾ãã®ã§æ³¨æãå¿ è¦ã§ãï¼åèï¼ã
ãã¡ã¤ã³åã«ã¯æ±äº¬ãªã¼ã¸ã§ã³ã¨åæ§ã«example.com
ã¨*.example.com
ãæå®ãã¾ããæ¤è¨¼æ¹æ³ã¯DNS validation
ãæå®ãã¾ãã
æ±äº¬ãªã¼ã¸ã§ã³ã¨åããã¡ã¤ã³åã§è¨¼ææ¸ãçºè¡ãã¦ãããããDNSæ¤è¨¼ã¯ä¸è¦ã§ãã
3. ALBã«è¨¼ææ¸ãè¨å®ãã
ALBã«è¨¼ææ¸ãè¨å®ããã«ã¹ã¿ã ãã¡ã¤ã³ï¼ããã§ã¯example.com
ï¼ã§HTTPSã¢ã¯ã»ã¹ã§ããããã«ãã¾ãã
Route 53ã«ALBã®CNAMEãç»é²ãã
ããã©ã«ãã§ã¯ãALBã¸ã®ã¢ã¯ã»ã¹ã«ã¯AWSææã®ãã¡ã¤ã³ï¼elb.amazonaws.com
ï¼ãæå®ãã¦ã¢ã¯ã»ã¹ãããã¨ã«ãªãã¾ãã®ã§ãã«ã¹ã¿ã ãã¡ã¤ã³ã§ã¢ã¯ã»ã¹ããããã«CNAMEã¬ã³ã¼ããè¨å®ãã¾ãã
ããã§ã¯ALBã®CNAMEã¨ãã¦www.example.com
ãæå®ãã¦ãã¾ãã
HTTPSãªã¹ãã¼ãä½æãã
ALBã«ãªã¹ãã¼ãä½æãã¾ãããããã³ã«ã¯HTTPSï¼443ï¼ãã証ææ¸ã¯ACMã§çºè¡ãããã®ãæå®ãã¾ãããã
ãªãSecurity Policyã®è¨å®ã¯ããã©ã«ãï¼ELBSecurityPolicy-2016-08
ï¼ã¨ãã¦ãã¾ãããæ¬ããªã·ã¼ã§ã¯TLS1.0ã¨TLS1.1ãæå¹åããã¦ãã¾ããããå®éã®ç°å¢ã§ã¯ã§ããã°é¿ããã»ããè¯ãã§ããããå
¬å¼ããã¥ã¡ã³ãã§ã¯äºææ§ã®ããããã©ã«ãå¤ãæ¨å¥¨...ã¨ããã¾ãããã»ãã¥ãªãã£ã¨äºææ§ã©ã¡ããåªå
ãããã¯ããã£ããæ¤è¨ããå¿
è¦ãããã¨æãã¾ãã
ãã¦HTTPSãªã¹ãã¼ãä½æããããåé ã§è¨å®ããCNAMEã使ã£ã¦ALBã«HTTPSã¢ã¯ã»ã¹ã§ããã確èªãã¦ããã¾ãããã
4. CloudFrontã«è¨¼ææ¸ãè¨å®ãã
CloudFrontã«è¨¼ææ¸ãè¨å®ããCloudFrontã«å¯¾ãã¦ãã«ã¹ã¿ã ãã¡ã¤ã³example.com
ã使ã£ã¦HTTPSã¢ã¯ã»ã¹ã§ããããã«ãã¾ãã
Route 53ã«CloudFrontã®CNAMEãç»é²ãã
ããã©ã«ãã§ã¯ãCloudFrontãã£ã¹ããªãã¥ã¼ã·ã§ã³ã¸ã®ã¢ã¯ã»ã¹ã«ã¯AWSææã®ãã¡ã¤ã³ï¼cloudfront.net
ï¼ãæå®ãã¦ã¢ã¯ã»ã¹ãããã¨ã«ãªãã¾ãã®ã§ãã«ã¹ã¿ã ãã¡ã¤ã³ã§ã¢ã¯ã»ã¹ããããã«CNAMEã¬ã³ã¼ããè¨å®ãã¾ãã
CloudFrontã«è¨¼ææ¸ãè¨å®ãã
CloudFrontã®ã«ã¹ã¿ã 証ææ¸ã¨ãã¦ãACMã§çºè¡ãã証ææ¸ãè¨å®ãã¾ãã
ç¶ãã¦ããã¤ãã¢ãç·¨éããViewer protocol policy
ãHTTPS Onlyã«å¤æ´ãã¾ããã©ã®è¨å®å¤ã§ãHTTPSã¯å©ç¨ã§ããã®ã§ãããä»åã¯HTTPS Only
ã¨ãã¾ããã
以ä¸ã§ã¯ã©ã¤ã¢ã³ãï½CloudFrontéã®HTTPSè¨å®ã¯å®äºã§ãã
æå¾ã«CloudFrontï½ALBéã§HTTPSãå©ç¨ããããè¨å®ãã¾ãããªãªã¸ã³ã®è¨å®ãç·¨éããOrigin domain
ã§ALBã®CNAMEããProtocol
ã§HTTPS Only
ãæå®ãã¾ãã
以ä¸ã§ãCloudFrontï½ALBéã®HTTPSè¨å®ã¯å®äºã§ãã
åä½ç¢ºèª
CloudFrontãã£ã¹ããªãã¥ã¼ã·ã§ã³ã®CNAMEã«HTTPSã§æ¥ç¶ã§ãã¾ããã
証ææ¸ãCloudFrontããã©ã«ãã®ãã®ã§ã¯ãªããã«ã¹ã¿ã ãã¡ã¤ã³ã®ãã®ã使ããã¦ãã¾ãã
ã¾ã¨ã
ã¨ãããã¨ã§ãç°¡åã§ããã¯ã©ã¤ã¢ã³ãï½CloudFrontéã¨CloudFrontï½ALBéã®ä¸¡æ¹ã§HTTPSãè¨å®ããæ¹æ³ãã¾ã¨ãã¾ãããç»å ´ãããµã¼ãã¹ãå¢ãã¦ããã¨ããã¥ã¡ã³ããèªã¿è§£ãã®ãä¸è¦å´ã§ããã
åèè¨äº
ACMã§ãããªãã¯è¨¼ææ¸ããªã¯ã¨ã¹ãããï¼ https://docs.aws.amazon.com/ja_jp/acm/latest/userguide/gs-acm-request-public.html
ãªã¯ã¨ã¹ããã証ææ¸ã®DNSæ¤è¨¼ï¼ https://docs.aws.amazon.com/ja_jp/acm/latest/userguide/dns-validation.html
HTTPSãªã¹ãã¼ãä½æããï¼ https://docs.aws.amazon.com/ja_jp/elasticloadbalancing/latest/application/create-https-listener.html#describe-ssl-policies
ã¯ã©ã¤ã¢ã³ãï½CloudFrontãã£ã¹ããªãã¥ã¼ã·ã§ã³éã§HTTPSã使ç¨ããï¼ https://docs.aws.amazon.com/ja_jp/AmazonCloudFront/latest/DeveloperGuide/using-https-viewers-to-cloudfront.html
CloudFrontï½ALBéã§HTTPSã使ç¨ããï¼ https://docs.aws.amazon.com/ja_jp/AmazonCloudFront/latest/DeveloperGuide/using-https-cloudfront-to-custom-origin.html
CloudFrontã§ã«ã¹ã¿ã ãã¡ã¤ã³ã使ç¨ããï¼ https://docs.aws.amazon.com/ja_jp/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html
æ¾ç° æ¸(è¨äºä¸è¦§)
2021å¹´10æå
¥ç¤¾ãæ£æ©ãå¾æã§ãã