Skip to content

Latest commit

ย 

History

History
230 lines (176 loc) ยท 11.4 KB

File metadata and controls

230 lines (176 loc) ยท 11.4 KB

Https

OKKY๋ฅผ ํ†ตํ•ด ๋ณธ ์ตœ์‹  ๊ธฐ์ˆ  HTTP/3

Https vs Http

Http ๋Š” ์›น์„œ๋ฒ„์™€ ์‚ฌ์šฉ์ž์˜ ๋ธŒ๋ผ์šฐ์ € ์‚ฌ์ด์— ๋ฌธ์„œ๋ฅผ ์ „์†กํ•˜๊ธฐ ์œ„ํ•œ ํ”„๋กœํ† ์ฝœ์ž…๋‹ˆ๋‹ค. ์ด ํ”„๋กœํ† ์ฝœ์€ ์„œ๋ฒ„์™€ ์ฃผ๊ณ ๋ฐ›์€ ์ •๋ณด๊ฐ€ ์•”ํ˜ธํ™” ๋˜์–ด์žˆ์ง€ ์•Š๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ๋ฅผ ์‰ฝ๊ฒŒ ๋„๋‚œ ๋‹นํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ๋‚˜์˜จ ๊ฒƒ์ด Http + SSL ์ด ํ•ฉ์ณ์ง„ ํ”„๋กœํ† ์ฝœ์ด๋‹ค. SSL(๋ณด์•ˆ ์†Œ์ผ“ ๊ณ„์ธต)์„ ์‚ฌ์šฉํ•จ์œผ๋กœ์จ ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ–ˆ๋‹ค. ๋˜ Https๋Š” ๋ณด์•ˆ์—์„œ๋งŒ ์ด๋“์„ ๋ณด๋Š”๊ฒƒ์ด ์•„๋‹ˆ๋ผ ๊ฒ€์ƒ‰์•ค์ง„ ์ตœ์ ํ™”์—์žˆ์–ด์„œ๋„ ์ด๋“์„ ๋ณธ๋‹ค.

Https ํ†ต์‹ ๊ณผ์ •

Http ๋Š” ํ†ต์‹ ํ•˜๊ธฐ ์œ„ํ•ด 3 way handshake๋ฅผ ํ•œ๋‹ค. ๊ทธ ํ›„ Secure Socker Layer ์˜ ํ†ต์‹  ์‹œ์ž‘ ๋‹จ๊ณ„์—์„œ ๋‹ค์‹œ HandShake ๊ณผ์ • ๊ฑฐ์นœ๋‹ค.

0. [Client โ†” Server] TCP 3-Way Handshake

SSL ๋จผ์ € TCP ์œ„์–ด์„œ ๋™์ž‘ํ•˜๊ธฐ ๋•Œ๋ฌธ์— TCP ์—ฐ๊ฒฐ์ด ๋จผ์ € ์„ฑ๋ฆฝ๋˜์–ด์•ผ ํ•œ๋‹ค.

1. [Client โ†’ Server] Client Hello

  • ์ž์‹ ์ด ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” Cipher Spec(์•”ํ˜ธํ™” ๋ฐฉ๋ฒ•) ๋ชฉ๋ก ์„ ๋ณด๋‚ธ๋‹ค.
  • Clinet Nonce(๋‚œ์ˆ˜) ๋ณด๋‚ธ๋‹ค. ๋‚œ์ˆ˜๋ฅผ ๋ณด๋‚ด๋Š” ์ด์œ ๋Š” ํ†ต์‹ ๋‚ด์šฉ์„ ํ†ต์งธ๋กœ ๊ฐ€์ ธ๊ฐ€ ๋ณต์‚ฌํ•˜๋Š” ํ–‰์œ„๋ฅผ ๋ง‰๊ธฐ์œ„ํ•ด์„œ ์ด๋‹ค. ์ƒˆ์…˜์‹๋ณ„์ž์™€ ๊ฐ™์€ ์ •๋ณด๋“ค์ด ๋ถ€๊ฐ€์ ์œผ๋กœ ์ „์†ก๋œ๋‹ค.

2. [Server โ†’ Client] Server Hello

  • Client ๊ฐ€ ๋ณด๋‚ธ ClinetHello ํŒจํ‚ท์„ ์ฒ˜๋ฆฌํ•œ ํ›„ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ๋ณด๋‚ธ Ciper Spec ์ค‘ ํ•˜๋‚˜๋ฅผ ์„ ํƒํ•œ ํ›„ Client ์—๊ฒŒ ์•Œ๋ฆฐ๋‹ค.
  • Server Certificate(์ธ์ฆ์„œ (๊ณต๊ฐœํ‚ค))
  • Server Nonce
  • CA ๊ฐ€ Certificate๊ฐ€ ๋ˆ„๊ตฌ์˜ ์†Œ์œ ์ธ์ง€ ๋ณด์ฆํ•˜๋ฏ€๋กœ, ์ด๊ณผ์ •์—์„œ ์„œ๋ฒ„๋Š” Client์—๊ฒŒ ์ž์‹ ์„ ์ธ์ฆํ•  ์ˆ˜ ์žˆ๋‹ค. ์ฆ‰, Client๋Š” ์ž์‹ ์ด ์ตœ์ดˆ์— ์˜๋„ํ–ˆ๋˜ Server์™€ ํ†ต์‹ ํ•˜๊ณ  ์žˆ์Œ์„ ์ด ๊ณผ์ •์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋˜๋Š” ๊ฒƒ์ด๋‹ค.

3. [Client โ†’ Server] Client Key Exchange

  • Encrypted Pre-master secret (PMS)

Client์—์„œ ์ผ์ข…์˜ ๋‚œ์ˆ˜ ๊ฐ’์ธ Pre-master secret(PMS)(server์™€ ํ†ต์‹ ํ•  ๋Œ€์นญํ‚ค๋กœ ํ™œ์šฉํ•  ๊ฐ’)๋ฅผ ์ƒ์„ฑํ•˜๊ณ , ์ด๋ฅผ Server์˜ Publiuc Key๋กœ ์•”ํ˜ธํ™”ํ•˜์—ฌ Server๋กœ ์ „์†กํ•ฉ๋‹ˆ๋‹ค.

์ดํ›„ Client์™€ Server๋Š” {PMS, Client Nonce, Server Nonce} ์ด ์„ธ ๊ฐ’์„ ๋ฐ”ํƒ•์œผ๋กœ ๊ฐ๊ฐ Encryption Key์™€ MAC Key๋ฅผ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค.

Encryption Key๋Š” ์ถ”ํ›„ ์‚ฌ์šฉ๋  ์•”ํ˜ธํ™” ํ†ต์‹ ์—์„œ ์‚ฌ์šฉํ•  ์•”ํ˜ธํ™” ์•Œ๊ณ ๋ฆฌ์ฆ˜์—์„œ ์‚ฌ์šฉ๋  Key์ด๊ณ ,

MAC(Message Authentication Code) Key๋Š” ๊ฐ SSL Message Block์—์„œ Message์˜ HMAC๊ฐ’ ๊ณ„์‚ฐ์— ์‚ฌ์šฉ๋  Key์ž…๋‹ˆ๋‹ค.

์ฐธ๊ณ ์ ์œผ๋กœ, SSL์˜ ๋ณด์•ˆ ํ†ต์‹ ์—์„œ ์‚ฌ์šฉ๋˜๋Š” Key๋Š” ๋Œ€์นญํ‚ค์ž…๋‹ˆ๋‹ค. ์ฆ‰, Client ๋ฐ Server์—์„œ ๊ฐ๊ฐ ๊ณ„์‚ฐํ•ด์„œ ์ƒ์„ฑํ•œ Key๋“ค์€ ์–‘์ธก์ด ๊ฐ™์€ ๊ฐ’์„ ๊ฐ–๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

  • ๋ณด์•ˆ ํ†ต์‹ ์„ ์œ„ํ•œ Key ์ƒ์„ฑ์ด ์™„๋ฃŒ๋˜์—ˆ์œผ๋ฏ€๋กœ, ์—ฌ๊ธฐ์„œ๋ถ€ํ„ฐ ์•”ํ˜ธํ™”๋œ ๋ณด์•ˆ ํ†ต์‹ ์ด ์‹œ์ž‘๋ฉ๋‹ˆ๋‹ค.

4. [Client โ†” Server] Handshake Integrity Check

๊ทธ ๋™์•ˆ ์ „์†กํ–ˆ๋˜ ๋ชจ๋“  Message๋“ค์— ๋Œ€ํ•œ MAC๊ฐ’ ์ด ๋‹จ๊ณ„๋ถ€ํ„ฐ ๋ณด์•ˆ ํ†ต์‹ ์ด ๊ฐ€๋Šฅํ•˜๋ฏ€๋กœ ๋ณธ๊ฒฉ์ ์œผ๋กœ Data๋ฅผ ๊ตํ™˜ํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ๊ทธ ์ด์ „์ด ํ•ด์•ผ ํ•  ์ผ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

๋ฐ”๋กœ ๊ทธ๊ฐ„ Handshake๊ณผ์ •์—์„œ ์ฃผ๊ณ ๋ฐ›์•˜๋˜ Message์˜ ๋ฌด๊ฒฐ์„ฑ(Integrity)๋ฅผ ๊ฒ€์ฆํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

์ฆ‰, ๋น„๋ก SSL Handshake๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์ด๋ฃจ์–ด์กŒ์ง€๋งŒ, ์ค‘๊ฐ„์— ํ˜น์‹œ ์žˆ์„์ง€ ๋ชจ๋ฅผ ๊ณต๊ฒฉ์ž๊ฐ€ Handshake Message๋ฅผ ๋ณ€์กฐํ–ˆ์„ ๊ฐ€๋Šฅ์„ฑ์ด ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด, Client๊ฐ€ ์ง€์› Cipher Spec ๋ชฉ๋ก์„ ๋ณด๋‚ผ ๋•Œ ๊ณต๊ฒฉ์ž๊ฐ€ ์ด๋ฅผ ๊ฐ€๋กœ์ฑ„์„œ ๋†’์€ ์•”ํ˜ธํ™” ์ˆ˜์ค€์˜ Spec์„ ์ œ๊ฑฐํ•œ๋‹ค๊ฑฐ๋‚˜, Server๊ฐ€ ์„ ํƒํ•œ Spec์„ ๋‚ฎ์€ ์•”ํ˜ธํ™” ์ˆ˜์ค€์˜ Spec์œผ๋กœ ๋ณ€์กฐํ•˜๋Š” ๊ณต๊ฒฉ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

์ด๋Š” PMS๊ฐ€ ๊ตํ™˜๋˜๊ธฐ ์ด์ „๊นŒ์ง€์˜ ํ†ต์‹ ์€ ๋ชจ๋‘ ์•”ํ˜ธํ™”๊ฐ€ ๋˜์ง€ ์•Š์€ ์ƒํƒœ๋กœ ์ด๋ฃจ์–ด์ง€๊ธฐ ๋•Œ๋ฌธ์— ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ ์•”ํ˜ธํ™” ํ†ต์‹ ์ด ๊ฐ€๋Šฅํ•ด์ง„ ์ฒซ ์‹œ์ ์— Client์™€ Server๋Š” ๊ฐ๊ฐ ๊ทธ ๋™์•ˆ ์ž์‹ ์ด ์ „์†กํ–ˆ๋˜ ๋ชจ๋“  Message๋“ค์˜ MAC๊ฐ’์„ ๊ณ„์‚ฐํ•ด์„œ ์ƒ๋Œ€์ธก์—๊ฒŒ ์ „์†กํ•ฉ๋‹ˆ๋‹ค.

์ƒ๋Œ€๋ฐฉ์œผ๋กœ๋ถ€ํ„ฐ ๋ฐ›์€ MAC๊ฐ’๊ณผ ๊ทธ ๋™์•ˆ ์ž์‹ ์ด ๋ฐ›์•˜๋˜ Message๋“ค๋กœ๋ถ€ํ„ฐ MAC๊ฐ’์„ ๋‹ค์‹œ ๊ณ„์‚ฐํ•œ ๊ฐ’์ด ์ผ์น˜ํ•˜๋Š”์ง€ ์—ฌ๋ถ€๋ฅผ ๊ฒ€์‚ฌํ•˜์—ฌ Handshake Message๋“ค์˜ ๋ฌด๊ฒฐ์„ฑ์„ ์ฒดํฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด Handshake๊ณผ์ •์˜ ๋ฌด๊ฒฐ์„ฑ ์ฒดํฌ๊นŒ์ง€ ๋ฌด์‚ฌํžˆ ํ†ต๊ณผ ํ•˜๋ฉด ์ด์ œ ๋น„๋กœ์†Œ ๋ณธ๊ฒฉ์ ์œผ๋กœ ๋ณด์•ˆ ํ†ต์‹ ์„ ํ†ตํ•œ Data ๊ตํ™˜์„ ์‹œ์ž‘ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค

์ •๋ฆฌ

  1. http ์œ„์—์„œ ๋™์ž‘ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋จผ์ € TCP 3way handshake๋ฅผ ์ˆ˜ํ–‰ํ•œ๋‹ค.
  2. ํด๋ผ์ด์–ธํŠธ๋Š” ์„œ๋ฒ„์—๊ฒŒ ์ž์‹ ์ด ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์•”ํ˜ธํ™” ๋ชฉ๋ก๊ณผ, client ๋‚œ์ˆ˜๋ฅผ ๋ณด๋‚ธ๋‹ค.๊ฐ์ข… sessionId ์™€ ๊ฐ™์€ ๋ถ€๊ฐ€์ •๋ณด๋ฅผ ๋ณด๋‚ธ๋‹ค.(ํ†ต์งธ๋กœ ๋ณต์‚ฌํ•ด ์‚ฌ์šฉํ•˜๋Š” ์ผ์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด)
  3. ์„œ๋ฒ„๋Š” ํด๋ผ์ด์–ธํŠธ๊ฐ€ ๋ณด๋‚ธ ์•”ํ˜ธํ™”๋ชฉ๋ก์ค‘ ๊ฐ€์žฅ ๊ฐ•๋ ฅํ•œ ์ŠคํŽ™์„ ๊ณจ๋ผ ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ server ๋‚œ์ˆ˜, ์„œ๋ฒ„์˜ ๊ณต๊ฐœํ‚ค๊ฐ€ ๋‹ด๊ธด ์ธ์ฆ์„œ๋ฅผ ๋ณด๋‚ธ๋‹ค.
  4. ๋Œ€์นญํ‚ค๋กœ ์‚ฌ์šฉ๋  Pre-master secret(PMA)๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์„œ๋ฒ„์˜ public key๋กœ ์•”ํ˜ธํ™” ํ•œ๋‹ค. ์ดํ›„ ์„œ๋ฒ„์™€ ํด๋ผ์ด์–ธํŠธ๋Š” PMS์™€ ๋‚œ์ˆ˜๊ฐ’์„ ๋ฐ”ํƒ•์œผ๋กœ Encryption key(๋Œ€์นญํ‚ค)์™€ Mac key๋ฅผ ๊ณ„์‚ฐํ•œ๋‹ค.
  5. handShake ๊ณผ์ •์—์„œ ์ฃผ๊ณ ๋ฐ›์•˜๋˜ Message์˜ ๋ฌด๊ฒฐ์„ฑ์„ ๊ฒ€์ฆํ•œ ํ›„ ์•”ํ˜ธํ™” ํ†ต์‹ ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

๋Œ€์นญํ‚ค์™€ ๋น„๋ฐ€ํ‚ค

๋Œ€์นญํ‚ค: ์†ก์‹ ์ž ์ˆ˜์‹ ์ž๊ฐ€ ๊ฐ™์€ ๋น„๋ฐ€ํ‚ค๋ฅผ ๊ฐ–๊ณ  ์•”ํ˜ธํ™” ๋ณตํ˜ธํ™”๋ฅผ ํ•จ ๋น„๋ฐ€ํ‚ค: ์†ก์‹ ์ž ์ˆ˜์‹ ์ž‘๊ฐ ๊ฐ์ž์˜ ๊ณต๊ฐœํ‚ค/๊ฐœ์ธํ‚ค๋ฅผ ๊ฐ–๊ณ ์žˆ๋‹ค.

SSL ์„ค์ •

  • nginx๊ฐ€ 80 ํฌํŠธ๋ฅผ listen ํ•˜๊ณ  ์žˆ๋‹ค. ๊ทธ๋Ÿด๊ฒฝ์šฐ 301 redirect๋กœ https ๋กœ ์š”์ฒญํ•œ๋‹ค.

  • ํ•ด๋‹น์š”์ฒญ์„ ๋ณด๋‚ด๋ฉด proxy_pass ๋กœ ํ†ฐ์ผ“์œผ๋กœ ์š”์ฒญ์„ ๋ณด๋‚ธ๋‹ค.

protocol

ssl_protocols TLSv1.1 TLSv1.2;

์‚ฌ์šฉํ•  ํ”„๋กœํ† ์ฝœ์„ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค. SSL ํ”„๋กœํ† ์ฝœ์€ ๋„ˆ๋ฌด ์˜ค๋ž˜๋๊ธฐ๋•Œ๋ฌธ์— ์ด์ œ ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ๋ณด์•ˆ์„ ๋” ๊ณ ๋ คํ•œ๋‹ค๋ฉด TLSv1.0๊ณผ TLSv1.1 ์ง€์›์„ ์ค‘๋‹จํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค๊ณ  ํ•œ๋‹ค. ์ด๋ฏธ TLSv1.0์€ ์‹œ์žฅ์—์„œ ์ง€์›์ด ์ค‘๋‹จ๋œ ์ƒํƒœ์ด๊ธฐ๋„ ํ•œ๋‹ค.

oscp stapling

ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์ธ์ฆ์„œ๊ฐ€ ํ๊ธฐ๋œ๊ฒƒ์ธ์ง€ ํ™•์ธํ•™๊ธฐ ์œ„ํ•ด ํ™•์ธํ•ด์•ผํ•œ๋‹ค. CRL ,OCSP ,OCSP Stapling 3๊ฐ€์ง€ ๋ฐฉ์‹์ด ์žˆ๋Š”๋ฐ

  • CRL์€ ํŽ˜๊ธฐ ์ธ์ฆ์„œ๋ฅผ ๋‹ค ๋ฐ›์•„์™€ ํ™•์ธํ•˜๋Š” ๋ฐฉ๋ฒ•,
  • OCSP ์€ client๊ฐ€ CA db์— ์ ‘์†ํ•ด ํ™•์ธํ•˜๋Š” ๊ฒƒ
  • OSCP Stapling ์€ ์›น์„œ๋ฒ„๊ฐ€ ์ธ์ฆ์„œ๊ฐ€ ์œ ํšจํ•˜๋‹ค๋Š” ์ฆ๋ช…์„ ๋ฏธ๋ฆฌ ๋ฐ›์•„๋‘์–ด์„œ ์ ‘์†์†๋„๋ฅผ ๋นจ๋ผ์ง€๊ฒŒํ•จ ๊ทธ ์ค‘์— OCSP Stapling๋ฅผ ์„ค์ •ํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ๋”ฐ๋ผ์„œ ์„ฑ๋Šฅ์„ ๋†’์ผ ์ˆ˜ ์žˆ๋‹ค.
ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /etc/letsencrypt/live/chat-sellerlee.tk/chain.pem;  #์ธ์ฆ์„œ ๋ฐœ๊ธ‰์ž

ssl session

ssl handshake๊ฐ€ ๋˜๊ณ ๋‚˜์„œ session์„ ์ ์šฉ์‹œ์ผœ ๊ณ„์† ssl ์„ ์œ ์ง€์‹œ์ผœ์ค€๋‹ค. session_tickets ์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š์œผ๋ฉด session Id๋ฅผ ์ด์šฉํ•˜๋Š”๋ฐ session Id ๋””๋น„์— ์ €์žฅ๋˜์–ด์•ผํ•˜๊ณ  ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์žก์•„๋จน์„ ์ˆ˜์žˆ๋‹ค

๋ถ„์‚ฐํ™˜๊ฒฝ์— ๊ฒฝ์šฐ ์–ด๋ ค์›€์ด ์žˆ์ง€๋งŒ ticket์€ L4์— ์˜ํ–ฅ์„ ๋ฐ›์ง€ ์•Š๋Š”๋‹ค.

ssl_session_cache shared:SSL:10m; # a cache shared between all worker processes. 
ssl_session_timeout 10m;
ssl_session_tickets on;

dhparam

ํ‚ค ๊ตํ™˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜์— ์‚ฌ์šฉ๋  dhparam ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋‹ค. openSSL์„ ์ด์šฉํ•ด ํ•ด๋‹น ํด๋”๋กœ ๋‹ค์šด๋กœ๋“œ ํ•˜์˜€๋‹ค.

์ผ๋ฐ˜์ ์œผ๋กœ SSL/TLS๋งŒ ์ ์šฉํ•ด๋„ ๋˜์ง€๋งŒ ๋ณด์•ˆ์„ ๋”์šฑ ๊ฐ•ํ™”ํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋ณด์•ˆํ‚ค ์ˆ˜์ค€์„ ๋†’์ธ๋‹ค.

nginx๋Š” openssl์—์„œ ์ œ๊ณตํ•˜๋Š” ๊ธฐ๋ณธ DHE (Ephemeral Diffie-Hellman)๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

์ด๋Š” 1024๋น„ํŠธ์— ๊ธฐ๋ฐ˜ํ•œ๋‹ค. ๊ทธ๋ž˜์„œ nginx ์ž์ฒด๊ฐ€ ์•„๋‹Œ ์‚ฌ์šฉ์ž๊ฐ€ ๋” ๋†’์€ ๋ณด์•ˆ์„ ๋‹ด๋ณดํ•˜๋Š” ํ‚ค๋ฅผ ์ƒ์„ฑํ•ด ์ค๋‹ˆ๋‹ค.

ssl_ecdh_curve ๋Š” dhparam์— ์‚ฌ์šฉ๋  ํƒ€์›๊ณก์„ ์„ ๊ตฌ์ฒดํ™” ํ•œ๋‹ค.

ssl_ecdh_curve auto;
ssl_dhparam /etc/letsencrypt/dhparam.pem;

header

X-Frame-Options

ํด๋ฆญ์žฌํ‚น ๋ฐฉ์–ด๋ฅผ ์œ„ํ•ด ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ํด๋ฆญ์žฌํ‚น์ด๋ž€ ๊ณต๊ฒฉ์ž๊ฐ€ ์›ํ•˜๋Š” ๊ฒƒ์„ ํด๋ฆญํ•˜๋„๋ก ์†์ด๋Š” ํ•ดํ‚น๊ธฐ๋ฒ•์ด๋‹ค.

X-Frame-Options: sameorigin always;

option

  • deny: ๋ชจ๋“  ํ”„๋ ˆ์ž„์„ ๋ฌดํšจํ™”
  • sameorigin: ๋„๋ฉ”์ธ ๊ธฐ์ค€์œผ๋กœ ๊ฐ™์€ origin(์„œ๋ฒ„) ์—์„œ๋Š” ๋ Œ๋”๋ง์„ ํ—ˆ์šฉ
  • allow-from https://example.com/์€ ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ๋Š” ์ฃผ์†Œ๋ฅผ ์„ค์ •

X-Content-Type-Options

์ž˜๋ชป๋œ MINEํƒ€์ž…์ด ํฌํ•จ๋œ ์‘๋‹ต์ด ์žˆ์œผ๋ฉด ๊ฑฐ๋ถ€ํ•˜๋Š” ์˜ต์…˜์ด๋‹ค.

add_header X-Content-Type-Options nosniff;

X-XSS-Protection

XSS๋ฅผ ํ†ตํ•œ ์„ธ์…˜ ํ•˜์ด์ œํ‚น์„ ๋ง‰๋„๋กํ•˜๋Š” ๋ช…๋ น์œผ๋กœ ์•„๋ž˜ ๋„ค๊ฐ€์ง€ ์˜ต์…˜์ด ์žˆ๋‹ค.

add_header "X-XSS-Protection" "1; mode=block";

ํฌ๋กœ์Šค์‚ฌ์ดํŠธ์Šคํฌ๋ฆฝํŠธ๋ฅผ ํƒ์ง€ํ•˜๋ฉด ์›น ํŽ˜์ด์ง€๋ฅผ ์‚ฌ์šฉ์ž์—๊ฒŒ ์•„์˜ˆ ๋ณด์—ฌ์ฃผ์ง€๋„ ๋ง๋ผ๋Š” ์˜๋ฏธ์ด๋‹ค.

  • X-XSS-Protection: 0
    • XSS ํ•„ํ„ฐ๋ง์„ ๋น„ํ™œ์„ฑํ™”
  • X-XSS-Protection: 1
    • ํฌ๋กœ์Šค์‚ฌ์ดํŠธ์Šคํฌ๋ฆฝํŠธ ๊ณต๊ฒฉ๋งŒ ์ฐจ๋‹จํ•˜๊ณ  ์›นํŽ˜์ด์ง€๋Š” ์ •์ƒ์ ์œผ๋กœ ์ถœ๋ ฅ
  • X-XSS-Protection: 1; mode=block
    • ํฌ๋กœ์Šค์‚ฌ์ดํŠธ์Šคํฌ๋ฆฝํŠธ๋ฅผ ํƒ์ง€ํ•˜๋ฉด ์›น ํŽ˜์ด์ง€๋ฅผ ์‚ฌ์šฉ์ž์—๊ฒŒ ์•„์˜ˆ ๋ณด์—ฌ์ฃผ์ง€๋„ ๋ง๋ผ๋Š” ์˜๋ฏธ
  • X-XSS-Protection: 1; report=
    • ํฌ๋กœ์Šค์‚ฌ์ดํŠธ์Šคํฌ๋ฆฝํŠธ๋ฅผ ํƒ์ง€ํ•˜๋ฉด ํŽ˜์ด์ง€ ๋ Œ๋”๋ง์„ ์ฐจ๋‹จํ•˜๊ณ  ์œ„๋ฐ˜ ์‚ฌํ•ญ์„ ๋ณด๊ณ 

      ์ด๊ฒƒ์€ CSP report-uri ์ง€์‹œ๋ฌธ์˜ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ณด๊ณ ์„œ๋ฅผ ๋ณด๋ƒ„

Strict-Transport-Security

Https๋งŒ์„ ์‚ฌ์šฉํ•˜์—ฌ ํ†ต์‹ ํ•ด์•ผ ํ•œ๋‹ค๊ณ  ๋ธŒ๋ผ์šฐ์ €์— ์•Œ๋ฆฌ๋Š” ๋ณด์•ˆ๊ธฐ๋Šฅ

add_header Strict-Transport-Security "max-age=63072000" always;

max-age ๋งŒํผ Https๋กœ ์ ‘๊ทผํ•ด์•ผํ•œ๋‹ค๊ณ  ๊ธฐ์–ต๋จ

Content-Security-Policy

CSP (Content Security Policy)๋Š” XSS๋‚˜ Data Injection, Click Jacking, ๋“ฑ ์›น ํŽ˜์ด์ง€์— ์•…์„ฑ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‚ฝ์ž…ํ•˜๋Š” ๊ณต๊ฒฉ๊ธฐ๋ฒ•๋“ค์„ ๋ง‰๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋œ๋‹ค.

add_header Content-Security-Policy "default-src 'self'; ";

๋ชจ๋“  ์ปจํ…์ธ ์˜ ์†Œ์Šค๋Š” ์ž๊ธฐ ๋„๋ฉ”์ธ์—์„œ ๊ฐ–๊ณ  ์˜ค๊ฒŒ ๋œ๋‹ค. ์„œ๋ธŒ๋„๋ฉ”์ธ์€ ์ œ์™ธ๋‹ค. ๋ผ๋Š” ์˜๋ฏธ

  • ์ฐธ๊ณ 

Referrer-Policy

Referrer ๋ž€ ์ด์ „๋ฐฉ๋ฌธ ํŽ˜์ด์ง€๋ฅผ ๋งํ•œ๋‹ค. ํ•ด๋‹น ์ •์ฑ…์€ referrer ์ •๋ณด๋ฅผ ์–ด๋–ป๊ฒŒ ์ปจํŠธ๋กคํ• ๊ฑด์ง€ ์ •ํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

Referrer-Policy: no-referrer
Referrer-Policy: no-referrer-when-downgrade
Referrer-Policy: origin
Referrer-Policy: origin-when-cross-origin
Referrer-Policy: same-origin
Referrer-Policy: strict-origin
Referrer-Policy: strict-origin-when-cross-origin
Referrer-Policy: unsafe-url
add_header Referrer-Policy "strict-origin-when-cross-origin";
  • ๊ฐ™์€ํ™ˆํŽ˜์ด์ง€๋Š” ์ „์ฒด์ฃผ์†Œ ๋‹ค๋ฅธ https๊ฐˆ๋•Œ๋Š” ๋„๋ฉ”์ธ์ฃผ์†Œ๋งŒ, http๋กœ ๊ฐˆ๋•Œ๋Š” ์ œ๊ฑฐ์ด๋‹ค.

  • ์ฐธ๊ณ 

Permissions-Policy

  • ๋ธŒ๋ผ์šฐ์ €์˜ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ• ์ง€ ๊ฒฐ์ •ํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

๊ฒฐ๊ณผ