๐Ÿ“ฆ AWS ELB์™€ ACM๋กœ https ํ™˜๊ฒฝ ๊ตฌ์„ฑํ•˜๊ธฐ

๊ฐœ์š”

๋‹จ์ผ ์„œ๋ฒ„๋กœ๋งŒ ๊ตฌ์„ฑ๋œ ํ”„๋กœ์ ํŠธ์—๋Š” Letโ€™s Encrypt ๋ฅผ ์ด์šฉํ•ด SSL ์ธ์ฆ์„œ๋ฅผ ๋ฐœ๊ธ‰ ๋ฐ ์ ์šฉํ•ด์™”๋Š”๋ฐ,

์ด๋ฒˆ ํ”„๋กœ์ ํŠธ์—๋Š” AWS ํ™˜๊ฒฝ์—์„œ ELB ๋ฅผ ์—ฐ๊ฒฐํ•ด์„œ Certificate Manager ์ธ์ฆ์„œ๋กœ https ํ™˜๊ฒฝ์„ ๊ตฌ์„ฑํ•ด๋ณด๊ธฐ๋กœ ํ–ˆ๋‹ค.

๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ ์ƒ์„ฑ

AWS EC2 > ๋กœ๋“œ ๋ฐธ๋Ÿฐ์‹ฑ > ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ์—์„œ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ ์ƒ์„ฑ์„ ํด๋ฆญํ•œ๋‹ค.

๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ ํƒ€์ž… ์„ ํƒ ํ™”๋ฉด์ด ๋ณด์ด๋ฉด ์ขŒ์ธก์˜ Application Load Balancer๋ฅผ ์„ ํƒํ•œ๋‹ค.

Application Load Balancer

๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ ์ด๋ฆ„, VPC, ๋„คํŠธ์›Œํฌ ๋งคํ•‘ ๋“ฑ ๊ธฐ๋ณธ ์„ค์ •์„ ํ•ด์ค€๋‹ค.

๋ฆฌ์Šค๋„ˆ์™€ ๋ผ์šฐํŒ… ์„ค์ • ๋ถ€๋ถ„์ด ์ค‘์š”ํ•œ๋ฐ, ๋ฆฌ์Šค๋„ˆ๋ฅผ ์ถ”๊ฐ€ํ•˜๋ ค๋ฉด ์„ค์ •๋œ ๊ฒฝ๋กœ(ํ”„๋กœํ† ์ฝœ, ํฌํŠธ)๋กœ ์š”์ฒญ์ด ๋“ค์–ด์™”์„ ๋•Œ ๋ฆฌ์Šค๋„ˆ๊ฐ€ ํฌ์›Œ๋”ฉํ•ด ์ค„ ํƒ€๊ฒŸ ๊ทธ๋ฃน์„ ๋งŒ๋“ค์–ด์•ผ ํ•œ๋‹ค.

ํ•˜์œ„์˜ Create target group ๋งํฌ๋ฅผ ๋ˆŒ๋Ÿฌ ํƒ€๊ฒŸ ๊ทธ๋ฃน์„ ์ƒ์„ฑํ•˜๋Ÿฌ ๊ฐ€๋ณด์ž.

Create target group

ํƒ€๊ฒŸ ๊ทธ๋ฃน ์ƒ์„ฑ

ํƒ€๊ฒŸ ๊ทธ๋ฃน ์ƒ์„ฑ ํŽ˜์ด์ง€์—์„œ ํƒ€๊ฒŸ ์œ ํ˜•์€ ์ธ์Šคํ„ด์Šค๋ฅผ ์„ ํƒํ–ˆ๋‹ค.

Select target type

๋Œ€์ƒ ์ธ์Šคํ„ด์Šค๋Š” 80๋ฒˆ ํฌํŠธ๋กœ ์—ฐ๊ฒฐ๋˜์–ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์— HTTP:80์œผ๋กœ ์„ค์ •ํ•œ๋‹ค.

Setting protocol and port

ํ•„์ž๋Š” ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ๋ฅผ ์„ค์ •ํ•˜๋ฉด http๋กœ ๋“ค์–ด์˜ค๋ฉด https๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธํ•  ๊ณ„ํš์ด๊ธฐ ๋•Œ๋ฌธ์—, Health checks > Advanced health check settings์—์„œ Success codes๋ฅผ 301๋ฒˆ์œผ๋กœ ์„ค์ •ํ–ˆ๋‹ค.

Setting health check path

Secure listener settings์—์„œ๋Š” SSL ์ธ์ฆ์„œ๋ฅผ ์—ฐ๊ฒฐํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค.

์šฐ์ธก ํ•˜๋‹จ์˜ Request new ACM certificate ๋งํฌ๋ฅผ ๋ˆŒ๋Ÿฌ SSL ์ธ์ฆ์„œ๋ฅผ ๋ฐœ๊ธ‰ํ•˜๋Ÿฌ ๊ฐ€์ž.

Request new ACM certificate

Certificate Manager ์ธ์ฆ์„œ ์š”์ฒญ

AWS Certificate Manager > ์š”์ฒญ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๊ณ  ํผ๋ธ”๋ฆญ ์ธ์ฆ์„œ ์š”์ฒญ์„ ํ•ด๋ณด์ž.

AWS Certificate Manager

๋„๋ฉ”์ธ ์ด๋ฆ„์„ ์ž‘์„ฑํ•˜๊ณ  ํ•ด๋‹น ๋„๋ฉ”์ธ ์†Œ์œ ๋ฅผ ๊ฒ€์ฆํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์„ DNS์™€ ์ด๋ฉ”์ผ ์ค‘์— ์„ ํƒํ•œ๋‹ค.

๊ฒ€์ฆ์ด ์™„๋ฃŒ๋˜๋ฉด ๋ฐœ๊ธ‰๋จ ์ƒํƒœ๊ฐ€ ๋œ๋‹ค.

DNS check

์ธ์ฆ์„œ ๋ฐœ๊ธ‰์ด ์™„๋ฃŒ๋˜๋ฉด ํƒ€๊ฒŸ ๊ทธ๋ฃน ์„ค์ • ํŽ˜์ด์ง€๋กœ ๋Œ์•„์™€ ๋ฐฉ๊ธˆ ๋งŒ๋“  ACM์„ ์„ ํƒํ•˜๊ณ  ๋‹ค์Œ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅธ๋‹ค.

Register Targets ํŽ˜์ด์ง€์—์„œ ์—ฐ๊ฒฐํ•  ์ธ์Šคํ„ด์Šค๋ฅผ 80๋ฒˆ ํฌํŠธ๋กœ ๋“ฑ๋กํ•œ๋‹ค.

http ์š”์ฒญ์„ https๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธํ•˜๊ธฐ

์ด์ œ ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ ์ƒ์„ฑ ํŽ˜์ด์ง€๋กœ ๋Œ์•„์™€ ์ƒ์„ฑํ•œ ํƒ€๊ฒŸ ๊ทธ๋ฃน์„ http/https ๋ฆฌ์Šค๋„ˆ์— ๋ชจ๋‘ ์—ฐ๊ฒฐํ•ด์ฃผ๊ณ  ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ ์ƒ์„ฑ์„ ๋งˆ์นœ๋‹ค.

๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ ํŽ˜์ด์ง€์—์„œ ์ƒ์„ฑํ•œ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๋ฅผ ์ฒดํฌํ•˜๊ณ  ํ•˜์œ„์˜ ๋ฆฌ์Šค๋„ˆ ํƒญ์„ ํด๋ฆญํ•œ๋‹ค.

Click listener

http๋กœ ์š”์ฒญ์ด ๋“ค์–ด์˜ค๋ฉด https๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ ๋˜๋„๋ก ์„ค์ •ํ•ด๋ณด์ž.

https:443 ๋ฆฌ์Šค๋„ˆ๋ฅผ ์„ ํƒํ•˜๊ณ  ํŽธ์ง‘ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ด์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„ค์ •ํ•ด์ค€๋‹ค.

Listener details

์ด์ œ ๋‹ค์‹œ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ ํŽ˜์ด์ง€๋กœ ๋Œ์•„์™€ ์„ค๋ช… ํƒญ์—์„œ DNS ์ด๋ฆ„์„ ๋ณต์‚ฌํ•œ ํ›„, ๋„๋ฉ”์ธ ๊ด€๋ฆฌ ์‚ฌ์ดํŠธ์—์„œ ํ•ด๋‹น ๋„๋ฉ”์ธ์˜ A๋ ˆ์ฝ”๋“œ ํ˜น์€ CNAME์— ๊ฐ’์„ ์—…๋ฐ์ดํŠธ ํ•ด์ฃผ๋ฉด ๋์ด๋‹ค.

https ํ™˜๊ฒฝ์„ ๊ตฌ์„ฑํ•˜๋Š” ๊ฒƒ๋„ ์„ค๊ณ„๋ฅผ ์–ด๋–ป๊ฒŒ ํ•˜๋Š๋ƒ์— ๋”ฐ๋ผ ๋‹ฌ๋ผ์งˆ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์ฐธ๊ณ ๋งŒ ํ•ด์ฃผ์‹œ๊ธธ ๋ฐ”๋ž€๋‹ค.

ELB์™€ ACM๋งŒ์œผ๋กœ SSL ์ธ์ฆ์„œ๋ฅผ ๋ฐœ๊ธ‰๋ฐ›๊ณ  https ์„œ๋ฒ„๋กœ ๋ผ์šฐํŒ… ํ•ด๋ณด์•˜๋Š”๋ฐ, ํƒ€๊ฒŸ ๊ทธ๋ฃน์ด๋‚˜ ๋ฆฌ์Šค๋„ˆ ์„ค์ • ๋ถ€๋ถ„์—์„œ ์กฐ๊ธˆ ํ—ค๋งค๊ธด ํ–ˆ์ง€๋งŒ ๋ณ„๋‹ค๋ฅธ ์ฝ”๋“œ ์ž‘์„ฑ ์—†์ด ์‰ฝ๊ฒŒ https ํ™˜๊ฒฝ์„ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ์ ์ด ๋†€๋ผ์› ๋‹ค.


Written by@ugaemi
Record things I want to remember

๐Ÿฑ GitHub๐Ÿ“š Reading Space