WEBãµã¼ãã¹ã§ä½¿ç¨ãããµã ãã¤ã«ç»åãJOBLISTã§ã¯äºåã«ä½ã£ã¦ããã®ã§ã¯ãªããåçã«çæãã¦ãã¾ãã
ãªãªã¸ãã«ç»åãhttps://d2ui2iytvnht76.cloudfront.net/sample.jpgã ã¨ããã¨ã
https://d2ui2iytvnht76.cloudfront.net/resize/100x100/sample.jpgã§100px à 100pxã«åã¾ãããã«ç¸®å°ããç»åã
https://d2ui2iytvnht76.cloudfront.net/crop/100x100/sample.jpgã§100px à 100pxã«ããã¿ãªåã¾ãããã«ç¸®å°ï¼åãæããããç»åã
ãåå¾ã§ãã¾ãã
ãããã¨æãã°ãã£ã¨è¤éãªãã¨ãåºæ¥ã¾ãããä»ã®ã¨ãããã®ãããã§äºè¶³ãã¦ã¾ãã
å°å ¥ã®ããã«ãã£ããã¨ã¯ãæ¢ã«æ§ç¯æ¸ã¿ã ã£ãCloudFrontã¨nginxã«è¨å®ã追å ããã ãã§ãã
ã·ã¹ãã æ§æ
ååã®ããã°ã®æ§æå³ã§ã¯ç»åé ä¿¡é¨åã®ç¢å°ãå°ãã¯ãããã¾ããã
å®éã¯ãããªæãã§ã
/resize/ã/crop/ã®å ´åã ãç»åå¤æãµã¼ããéãããã«ãªã£ã¦ãã¾ãã
ELBã¨ç»åå¤æãµã¼ãã¯ãµã¼ãã¹ç¨ã®ELBãappãµã¼ãã®æµç¨ã§ãã
è¨å®
CloudFront
CDNéããªãã¦ãåä½ã¯ãã¾ããããµã¼ãè² è·ãå¿çé度èããã¨ä½¿ã£ã¦ãããã»ããããããªã¨æãã¾ãã
è¨å®ã¯æé ã¨ãã¦ã¯ãoriginã«ELBã追å ãã¦ã
Behaviorè¨å®ã§/resize/ã/crop/ãªå ´åã®originãELBã«å¤æ´ããã ãã§ãã
ç»åå¤æãµã¼ãã§VirtualHostãå©ç¨ããå ´åã¯ãHostãããã転éãã¦ããããã«è¨å®ãã¾ãã
nginx
ç»åå¤æã«ã¯nginxã®image_filterã¢ã¸ã¥ã¼ã«ã使ã£ã¦ãã¾ãã
ãã®ã¢ã¸ã¥ã¼ã«ã¯ubuntuãamazon linuxã®æ¨æºã®nginxããã±ã¼ã¸ã«æåããå
¥ã£ã¦ããã®ã§ãã³ã³ãã£ã°è¿½å ããã ãã§ä½¿ãã¾ãã
server { listen 80; server_name xxx.cloudfront.net; location ~ ^/resize/(\d+)x(\d+)/(.*)$ { set $width $1; set $height $2; set $path $3; image_filter resize $width $height; image_filter_jpeg_quality 90; rewrite ^ /$path break; proxy_pass http://xxx.s3-website-ap-northeast-1.amazonaws.com; } location ~ ^/crop/(\d+)x(\d+)/(.*)$ { set $width $1; set $height $2; set $path $3; image_filter crop $width $height; image_filter_jpeg_quality 90; rewrite ^ /$path break; proxy_pass http://xxx.s3-website-ap-northeast-1.amazonaws.com; } }
ã¾ã¨ã
AWSãnginxã§ãæ軽ã«å°å ¥ã§ããåçãµã ãã¤ã«ã«ã¤ãã¦ã§ããã
æã¯åããã¨ããã®ãã£ããããã¸ãã§ããããä»ã¯ãããã楽ã«ãªã£ã¦ãããããã§ãã
ã¨ããããã§ãã¿ãª