NGINX Unit ๋ฐ Ubuntu๋กœ WordPress ์„ค์น˜ ์ž๋™ํ™”

NGINX Unit ๋ฐ Ubuntu๋กœ WordPress ์„ค์น˜ ์ž๋™ํ™”

WordPress ์„ค์น˜์— ๊ด€ํ•œ ๋งŽ์€ ์ž๋ฃŒ๊ฐ€ ์žˆ์œผ๋ฉฐ Google์—์„œ โ€œWordPress ์„ค์น˜โ€๋ฅผ ๊ฒ€์ƒ‰ํ•˜๋ฉด ์•ฝ XNUMX๋งŒ ๊ฐœ์˜ ๊ฒฐ๊ณผ๊ฐ€ ๋ฐ˜ํ™˜๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ WordPress์™€ ๊ธฐ๋ณธ ์šด์˜ ์ฒด์ œ๊ฐ€ ์žฅ๊ธฐ๊ฐ„ ์ง€์›๋  ์ˆ˜ ์žˆ๋„๋ก ์„ค์น˜ํ•˜๊ณ  ๊ตฌ์„ฑํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋˜๋Š” ์œ ์šฉํ•œ ๊ฐ€์ด๋“œ๋Š” ์‹ค์ œ๋กœ ๊ฑฐ์˜ ์—†์Šต๋‹ˆ๋‹ค. ์•„๋งˆ๋„ ์˜ฌ๋ฐ”๋ฅธ ์„ค์ •์€ ๊ท€ํ•˜์˜ ํŠน์ • ์š”๊ตฌ ์‚ฌํ•ญ์— ํฌ๊ฒŒ ์ขŒ์šฐ๋  ์ˆ˜๋„ ์žˆ๊ณ , ์ž์„ธํ•œ ์„ค๋ช…์œผ๋กœ ์ธํ•ด ๊ธฐ์‚ฌ๋ฅผ ์ฝ๊ธฐ๊ฐ€ ์–ด๋ ค์›Œ์กŒ์„ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด ๊ธฐ์‚ฌ์—์„œ๋Š” ์šฐ๋ถ„ํˆฌ์— WordPress๋ฅผ ์ž๋™์œผ๋กœ ์„ค์น˜ํ•˜๋Š” bash ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ œ๊ณตํ•˜์—ฌ ๋‘ ๊ฐ€์ง€ ์žฅ์ ์„ ๋ชจ๋‘ ๊ฒฐํ•ฉํ•˜๋ ค๊ณ  ๋…ธ๋ ฅํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๊ฐ ๋ถ€๋ถ„์˜ ๊ธฐ๋Šฅ๊ณผ ๋””์ž์ธ ์‹œ ์ ˆ์ถฉ์ ์„ ์„ค๋ช…ํ•˜๋ฉด์„œ ์ด๋ฅผ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๊ทธ๊ฒƒ. ์ˆ™๋ จ๋œ ์‚ฌ์šฉ์ž๋ผ๋ฉด ๊ธฐ์‚ฌ ๋ณธ๋ฌธ์„ ๊ฑด๋„ˆ๋›ฐ๊ณ  ๊ทธ๋ƒฅ ์‚ฌ์šฉํ•ด๋„ ๋ฉ๋‹ˆ๋‹ค. ๋Œ€๋ณธ์„ ๋ฐ›์•„ ๊ท€ํ•˜์˜ ํ™˜๊ฒฝ์—์„œ ์ˆ˜์ • ๋ฐ ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ์Šคํฌ๋ฆฝํŠธ์˜ ์ถœ๋ ฅ์€ Lets Encrypt๋ฅผ ์ง€์›ํ•˜๊ณ  NGINX ์žฅ์น˜์—์„œ ์‹คํ–‰๋˜๋ฉฐ ์‚ฐ์—…์šฉ์œผ๋กœ ์ ํ•ฉํ•œ ์‚ฌ์šฉ์ž ์ •์˜ WordPress ์„ค์น˜์ž…๋‹ˆ๋‹ค.

NGINX ์œ ๋‹›์„ ์‚ฌ์šฉํ•˜์—ฌ WordPress๋ฅผ ๋ฐฐํฌํ•˜๊ธฐ ์œ„ํ•ด ๊ฐœ๋ฐœ๋œ ์•„ํ‚คํ…์ฒ˜๋Š” ๋‹ค์Œ ํ•ญ๋ชฉ์— ์„ค๋ช…๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ค๋ž˜๋œ ๊ธฐ์‚ฌ, ์ด์ œ ์—ฌ๊ธฐ์„œ ๋‹ค๋ฃจ์ง€ ์•Š์€ ๋‚ด์šฉ๋„ ์ถ”๊ฐ€๋กœ ๊ตฌ์„ฑํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค(๋‹ค๋ฅธ ๋งŽ์€ ํŠœํ† ๋ฆฌ์–ผ์—์„œ์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ).

  • ์›Œ๋“œํ”„๋ ˆ์Šค CLI
  • Let's Encrypt ๋ฐ TLSSSL ์ธ์ฆ์„œ
  • ์ž๋™ ์ธ์ฆ์„œ ๊ฐฑ์‹ 
  • NGINX ์บ์‹ฑ
  • NGINX ์••์ถ•
  • HTTPS ๋ฐ HTTP/2 ์ง€์›
  • ํ”„๋กœ์„ธ์Šค ์ž๋™ํ™”

์ด ๊ธฐ์‚ฌ์—์„œ๋Š” ์ •์  ์ฒ˜๋ฆฌ ์„œ๋ฒ„, PHP ์ฒ˜๋ฆฌ ์„œ๋ฒ„ ๋ฐ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ๋™์‹œ์— ํ˜ธ์ŠคํŒ…ํ•˜๋Š” ํ•˜๋‚˜์˜ ์„œ๋ฒ„์— ์„ค์น˜ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๋Ÿฌ ๊ฐ€์ƒ ํ˜ธ์ŠคํŠธ ๋ฐ ์„œ๋น„์Šค๋ฅผ ์ง€์›ํ•˜๋Š” ์„ค์น˜๋Š” ๋ฏธ๋ž˜์˜ ์ž ์žฌ์ ์ธ ์ฃผ์ œ์ž…๋‹ˆ๋‹ค. ์ด ๊ธฐ์‚ฌ์— ์—†๋Š” ๋‚ด์šฉ์— ๋Œ€ํ•ด ๊ธ€์„ ์“ฐ๊ธธ ์›ํ•˜์‹œ๋ฉด ๋Œ“๊ธ€์„ ๋‚จ๊ฒจ์ฃผ์„ธ์š”.

์š”๊ตฌ ์‚ฌํ•ญ

  • ์„œ๋ฒ„ ์ปจํ…Œ์ด๋„ˆ(LXC ๋˜๋Š” Lxd), ์ตœ์†Œ 512MB RAM ๋ฐ Ubuntu 18.04 ์ด์ƒ์ด ์ตœ๊ทผ ์„ค์น˜๋œ ๊ฐ€์ƒ ๋จธ์‹  ๋˜๋Š” ์ผ๋ฐ˜ ํ•˜๋“œ์›จ์–ด ์„œ๋ฒ„.
  • ์ธํ„ฐ๋„ท ์ ‘์† ๊ฐ€๋Šฅ ํฌํŠธ 80 ๋ฐ 443
  • ์ด ์„œ๋ฒ„์˜ ๊ณต์šฉ IP ์ฃผ์†Œ์™€ ์—ฐ๊ฒฐ๋œ ๋„๋ฉ”์ธ ์ด๋ฆ„
  • ๋ฃจํŠธ ๊ถŒํ•œ(sudo)์œผ๋กœ ์ ‘๊ทผํ•ฉ๋‹ˆ๋‹ค.

์•„ํ‚คํ…์ฒ˜ ๊ฐœ์š”

์•„ํ‚คํ…์ฒ˜๋Š” ์„ค๋ช…๊ณผ ๋™์ผํ•ฉ๋‹ˆ๋‹ค. ์ด์ „, XNUMX๊ณ„์ธต ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ž…๋‹ˆ๋‹ค. ์ด๋Š” PHP ์—”์ง„์—์„œ ์‹คํ–‰๋˜๋Š” PHP ์Šคํฌ๋ฆฝํŠธ์™€ ์›น ์„œ๋ฒ„์—์„œ ์ฒ˜๋ฆฌ๋˜๋Š” ์ •์  ํŒŒ์ผ๋กœ ๊ตฌ์„ฑ๋ฉ๋‹ˆ๋‹ค.

NGINX Unit ๋ฐ Ubuntu๋กœ WordPress ์„ค์น˜ ์ž๋™ํ™”

์ผ๋ฐ˜ ์›์น™

  • ์Šคํฌ๋ฆฝํŠธ์˜ ๋งŽ์€ ๊ตฌ์„ฑ ๋ช…๋ น์€ ๋ฉฑ๋“ฑ์„ฑ์„ ์œ„ํ•œ if ์กฐ๊ฑด์œผ๋กœ ๋ž˜ํ•‘๋ฉ๋‹ˆ๋‹ค. ์ด๋ฏธ ์ค€๋น„๋œ ์„ค์ •์„ ๋ณ€๊ฒฝํ•  ์œ„ํ—˜ ์—†์ด ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์—ฌ๋Ÿฌ ๋ฒˆ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์Šคํฌ๋ฆฝํŠธ๋Š” ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์—์„œ ์†Œํ”„ํŠธ์›จ์–ด๋ฅผ ์„ค์น˜ํ•˜๋ ค๊ณ  ์‹œ๋„ํ•˜๋ฏ€๋กœ ํ•˜๋‚˜์˜ ๋ช…๋ น์œผ๋กœ ์‹œ์Šคํ…œ ์—…๋ฐ์ดํŠธ๋ฅผ ์ ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค(apt upgrade ์šฐ๋ถ„ํˆฌ์˜ ๊ฒฝ์šฐ).
  • ํŒ€์€ ์ปจํ…Œ์ด๋„ˆ์—์„œ ์‹คํ–‰ ์ค‘์ธ์ง€ ๊ฐ์ง€ํ•˜์—ฌ ๊ทธ์— ๋”ฐ๋ผ ์„ค์ •์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์„ค์ •์—์„œ ์‹œ์ž‘ํ•  ์Šค๋ ˆ๋“œ ํ”„๋กœ์„ธ์Šค ์ˆ˜๋ฅผ ์„ค์ •ํ•˜๊ธฐ ์œ„ํ•ด ์Šคํฌ๋ฆฝํŠธ๋Š” ์ปจํ…Œ์ด๋„ˆ, ๊ฐ€์ƒ ๋จธ์‹  ๋ฐ ํ•˜๋“œ์›จ์–ด ์„œ๋ฒ„์—์„œ ์ž‘๋™ํ•˜๊ธฐ ์œ„ํ•œ ์ž๋™ ์„ค์ •์„ ์ถ”์ธกํ•˜๋ ค๊ณ  ์‹œ๋„ํ•ฉ๋‹ˆ๋‹ค.
  • ์„ค์ •์„ ์„ค๋ช…ํ•  ๋•Œ ์šฐ๋ฆฌ๋Š” ํ•ญ์ƒ ์ž๋™ํ™”๋ฅผ ๋จผ์ € ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ์ž๋™ํ™”๊ฐ€ ์ฝ”๋“œํ˜• ์ธํ”„๋ผ๋ฅผ ๋งŒ๋“œ๋Š” ๊ธฐ์ดˆ๊ฐ€ ๋˜๊ธฐ๋ฅผ ๋ฐ”๋ž๋‹ˆ๋‹ค.
  • ๋ชจ๋“  ๋ช…๋ น์€ ์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค. ๋ฟŒ๋ฆฌ, ๊ธฐ๋ณธ ์‹œ์Šคํ…œ ์„ค์ •์„ ๋ณ€๊ฒฝํ•˜๊ธฐ ๋•Œ๋ฌธ์— WordPress ์ž์ฒด๋Š” ์ผ๋ฐ˜ ์‚ฌ์šฉ์ž๋กœ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.

ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ์„ค์ •

์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•˜๊ธฐ ์ „์— ๋‹ค์Œ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์„ค์ •ํ•˜์‹ญ์‹œ์˜ค.

  • WORDPRESS_DB_PASSWORD โ€” WordPress ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋น„๋ฐ€๋ฒˆํ˜ธ
  • WORDPRESS_ADMIN_USER - WordPress ๊ด€๋ฆฌ์ž ์‚ฌ์šฉ์ž ์ด๋ฆ„
  • WORDPRESS_ADMIN_PASSWORD - WordPress ๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ
  • WORDPRESS_ADMIN_EMAIL โ€” WordPress ๊ด€๋ฆฌ์ž ์ด๋ฉ”์ผ
  • WORDPRESS_URL โ€“ ๋‹ค์Œ์œผ๋กœ ์‹œ์ž‘ํ•˜๋Š” WordPress ์‚ฌ์ดํŠธ์˜ ์ „์ฒด URL https://.
  • LETS_ENCRYPT_STAGING โ€” ๊ธฐ๋ณธ์ ์œผ๋กœ ๋น„์–ด ์žˆ์ง€๋งŒ ๊ฐ’์„ 1๋กœ ์„ค์ •ํ•˜๋ฉด ์„ค์ •์„ ํ…Œ์ŠคํŠธํ•  ๋•Œ ์ธ์ฆ์„œ๋ฅผ ์ž์ฃผ ์š”์ฒญํ•˜๋Š” ๋ฐ ํ•„์š”ํ•œ Let's Encrypt์˜ ์Šคํ…Œ์ด์ง• ์„œ๋ฒ„๋ฅผ ์‚ฌ์šฉํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด ๋งŽ์€ ์š”์ฒญ์œผ๋กœ ์ธํ•ด Let's Encrypt๊ฐ€ ์ผ์‹œ์ ์œผ๋กœ IP ์ฃผ์†Œ๋ฅผ ์ฐจ๋‹จํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ๋Š” ์ด๋Ÿฌํ•œ WordPress ๊ด€๋ จ ๋ณ€์ˆ˜๊ฐ€ ์„ค์ •๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ณ  ๊ทธ๋ ‡์ง€ ์•Š์€ ๊ฒฝ์šฐ ์ข…๋ฃŒ๋ฉ๋‹ˆ๋‹ค.
์Šคํฌ๋ฆฝํŠธ ์ค„ 572-576์—์„œ ๊ฐ’์„ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. LETS_ENCRYPT_STAGING.

ํŒŒ์ƒ ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ์„ค์ •

55-61ํ–‰์˜ ์Šคํฌ๋ฆฝํŠธ๋Š” ํ•˜๋“œ ์ฝ”๋”ฉ๋œ ๊ฐ’์ด๋‚˜ ์ด์ „ ์„น์…˜์—์„œ ์„ค์ •๋œ ๋ณ€์ˆ˜์—์„œ ํŒŒ์ƒ๋œ ๊ฐ’์„ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค์Œ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

  • DEBIAN_FRONTEND="noninteractive" โ€” ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์ด ์Šคํฌ๋ฆฝํŠธ์—์„œ ์‹คํ–‰ ์ค‘์ด๋ฉฐ ์‚ฌ์šฉ์ž ์ƒํ˜ธ ์ž‘์šฉ ๊ฐ€๋Šฅ์„ฑ์ด ์—†์Œ์„ ์•Œ๋ ค์ค๋‹ˆ๋‹ค.
  • WORDPRESS_CLI_VERSION="2.4.0" โ€” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ WordPress CLI ๋ฒ„์ „์ž…๋‹ˆ๋‹ค.
  • WORDPRESS_CLI_MD5= "dedd5a662b80cda66e9e25d44c23b25c" โ€” WordPress CLI 2.4.0 ์‹คํ–‰ ํŒŒ์ผ์˜ ์ฒดํฌ์„ฌ(๋ฒ„์ „์€ ๋ณ€์ˆ˜์— ํ‘œ์‹œ๋จ) WORDPRESS_CLI_VERSION). 162ํ–‰์˜ ์Šคํฌ๋ฆฝํŠธ๋Š” ์ด ๊ฐ’์„ ์‚ฌ์šฉํ•˜์—ฌ ์˜ฌ๋ฐ”๋ฅธ WordPress CLI ํŒŒ์ผ์ด ๋‹ค์šด๋กœ๋“œ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.
  • UPLOAD_MAX_FILESIZE="16M" โ€” WordPress์— ์—…๋กœ๋“œํ•  ์ˆ˜ ์žˆ๋Š” ์ตœ๋Œ€ ํŒŒ์ผ ํฌ๊ธฐ์ž…๋‹ˆ๋‹ค. ์ด ์„ค์ •์€ ์—ฌ๋Ÿฌ ๊ณณ์—์„œ ์‚ฌ์šฉ๋˜๊ธฐ ๋•Œ๋ฌธ์— ํ•œ ๊ณณ์—์„œ ์„ค์ •ํ•˜๋Š” ๊ฒƒ์ด ๋” ์‰ฝ์Šต๋‹ˆ๋‹ค.
  • TLS_HOSTNAME= "$(echo ${WORDPRESS_URL} | cut -d'/' -f3)" โ€” WORDPRESS_URL ๋ณ€์ˆ˜์—์„œ ์ถ”์ถœ๋œ ์‹œ์Šคํ…œ ํ˜ธ์ŠคํŠธ ์ด๋ฆ„. ๋‚ด๋ถ€ WordPress ํ™•์ธ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ Let's Encrypt์—์„œ ์ ์ ˆํ•œ TLS/SSL ์ธ์ฆ์„œ๋ฅผ ์–ป๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
  • NGINX_CONF_DIR="/etc/nginx" โ€” ๊ธฐ๋ณธ ํŒŒ์ผ์„ ํฌํ•จํ•˜์—ฌ NGINX ์„ค์ •์ด ์žˆ๋Š” ๋””๋ ‰ํ„ฐ๋ฆฌ ๊ฒฝ๋กœ nginx.conf.
  • CERT_DIR="/etc/letsencrypt/live/${TLS_HOSTNAME}" โ€” ๋ณ€์ˆ˜์—์„œ ์–ป์€ WordPress ์‚ฌ์ดํŠธ์˜ Let's Encrypt ์ธ์ฆ์„œ ๊ฒฝ๋กœ TLS_HOSTNAME.

WordPress ์„œ๋ฒ„์— ํ˜ธ์ŠคํŠธ ์ด๋ฆ„ ํ• ๋‹น

์Šคํฌ๋ฆฝํŠธ๋Š” ๊ฐ’์ด ์‚ฌ์ดํŠธ์˜ ๋„๋ฉ”์ธ ์ด๋ฆ„๊ณผ ์ผ์น˜ํ•˜๋„๋ก ์„œ๋ฒ„์˜ ํ˜ธ์ŠคํŠธ ์ด๋ฆ„์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ๊ผญ ํ•„์š”ํ•œ ๊ฒƒ์€ ์•„๋‹ˆ์ง€๋งŒ, ์Šคํฌ๋ฆฝํŠธ์—์„œ ๊ตฌ์„ฑํ•œ ๋Œ€๋กœ ๋‹จ์ผ ์„œ๋ฒ„๋ฅผ ์„ค์ •ํ•  ๋•Œ SMTP๋ฅผ ํ†ตํ•ด ๋ณด๋‚ด๋Š” ๋ฉ”์ผ์„ ๋ณด๋‚ด๋Š” ๊ฒƒ์ด ๋” ํŽธ๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ

# Change the hostname to be the same as the WordPress hostname
if [ ! "$(hostname)" == "${TLS_HOSTNAME}" ]; then
  echo " Changing hostname to ${TLS_HOSTNAME}"
  hostnamectl set-hostname "${TLS_HOSTNAME}"
fi

/etc/hosts์— ํ˜ธ์ŠคํŠธ ์ด๋ฆ„ ์ถ”๊ฐ€

๋ถ€๊ฐ€ WP-ํฌ๋ก  ์ •๊ธฐ์ ์ธ ์ž‘์—…์„ ์‹คํ–‰ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋˜๋ฉฐ WordPress๊ฐ€ HTTP๋ฅผ ํ†ตํ•ด ์ž์ฒด์ ์œผ๋กœ ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. WP-Cron์ด ๋ชจ๋“  ํ™˜๊ฒฝ์—์„œ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ž‘๋™ํ•˜๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด ์Šคํฌ๋ฆฝํŠธ๋Š” ํŒŒ์ผ์— ํ•œ ์ค„์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ์€ / etc / ํ˜ธ์ŠคํŠธWordPress๊ฐ€ ๋ฃจํ”„๋ฐฑ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํ†ตํ•ด ์ž์ฒด์ ์œผ๋กœ ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ๋„๋ก ๋‹ค์Œ์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ

# Add the hostname to /etc/hosts
if [ "$(grep -m1 "${TLS_HOSTNAME}" /etc/hosts)" = "" ]; then
  echo " Adding hostname ${TLS_HOSTNAME} to /etc/hosts so that WordPress can ping itself"
  printf "::1 %sn127.0.0.1 %sn" "${TLS_HOSTNAME}" "${TLS_HOSTNAME}" >> /etc/hosts
fi

ํ›„์† ๋‹จ๊ณ„์— ํ•„์š”ํ•œ ๋„๊ตฌ ์„ค์น˜

๋‚˜๋จธ์ง€ ์Šคํฌ๋ฆฝํŠธ์—๋Š” ์ผ๋ถ€ ํ”„๋กœ๊ทธ๋žจ์ด ํ•„์š”ํ•˜๋ฉฐ ์ €์žฅ์†Œ๊ฐ€ ์ตœ์‹  ์ƒํƒœ๋ผ๊ณ  ๊ฐ€์ •ํ•ฉ๋‹ˆ๋‹ค. ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ๋ชฉ๋ก์„ ์—…๋ฐ์ดํŠธํ•œ ๋‹ค์Œ ํ•„์š”ํ•œ ๋„๊ตฌ๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ

# Make sure tools needed for install are present
echo " Installing prerequisite tools"
apt-get -qq update
apt-get -qq install -y 
  bc 
  ca-certificates 
  coreutils 
  curl 
  gnupg2 
  lsb-release

NGINX ์œ ๋‹› ๋ฐ NGINX ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ์ถ”๊ฐ€

์ด ์Šคํฌ๋ฆฝํŠธ๋Š” ๊ณต์‹ NGINX ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์—์„œ NGINX ์œ ๋‹›๊ณผ ์˜คํ”ˆ ์†Œ์Šค NGINX๋ฅผ ์„ค์น˜ํ•˜์—ฌ ์ตœ์‹  ๋ณด์•ˆ ์—…๋ฐ์ดํŠธ ๋ฐ ๋ฒ„๊ทธ ์ˆ˜์ •์ด ํฌํ•จ๋œ ๋ฒ„์ „์ด ์‚ฌ์šฉ๋˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ๋Š” NGINX ๋‹จ์œ„ ์ €์žฅ์†Œ๋ฅผ ์ถ”๊ฐ€ํ•œ ๋‹ค์Œ NGINX ์ €์žฅ์†Œ๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  ์ €์žฅ์†Œ ํ‚ค์™€ ์„ค์ • ํŒŒ์ผ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. apt, ์ธํ„ฐ๋„ท์„ ํ†ตํ•œ ์ €์žฅ์†Œ์— ๋Œ€ํ•œ ์•ก์„ธ์Šค๋ฅผ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.

NGINX ์žฅ์น˜์™€ NGINX์˜ ์‹ค์ œ ์„ค์น˜๋Š” ๋‹ค์Œ ์„น์…˜์—์„œ ์ง„ํ–‰๋ฉ๋‹ˆ๋‹ค. ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋ฅผ ์—ฌ๋Ÿฌ ๋ฒˆ ์—…๋ฐ์ดํŠธํ•˜์ง€ ์•Š๋„๋ก ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ๋ฏธ๋ฆฌ ์ถ”๊ฐ€ํ•˜์—ฌ ์„ค์น˜ ์†๋„๋ฅผ ๋†’์ž…๋‹ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ

# Install the NGINX Unit repository
if [ ! -f /etc/apt/sources.list.d/unit.list ]; then
  echo " Installing NGINX Unit repository"
  curl -fsSL https://nginx.org/keys/nginx_signing.key | apt-key add -
  echo "deb https://packages.nginx.org/unit/ubuntu/ $(lsb_release -cs) unit" > /etc/apt/sources.list.d/unit.list
fi

# Install the NGINX repository
if [ ! -f /etc/apt/sources.list.d/nginx.list ]; then
  echo " Installing NGINX repository"
  curl -fsSL https://nginx.org/keys/nginx_signing.key | apt-key add -
  echo "deb https://nginx.org/packages/mainline/ubuntu $(lsb_release -cs) nginx" > /etc/apt/sources.list.d/nginx.list
fi

NGINX, NGINX ์œ ๋‹›, PHP MariaDB, Certbot(Let's Encrypt) ๋ฐ ํ•ด๋‹น ์ข…์†์„ฑ ์„ค์น˜

๋ชจ๋“  ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๊ฐ€ ์ถ”๊ฐ€๋˜๋ฉด ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋ฅผ ์—…๋ฐ์ดํŠธํ•˜๊ณ  ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค. ์Šคํฌ๋ฆฝํŠธ๋กœ ์„ค์น˜๋œ ํŒจํ‚ค์ง€์—๋Š” WordPress.org๋ฅผ ์‹คํ–‰ํ•  ๋•Œ ๊ถŒ์žฅ๋˜๋Š” PHP ํ™•์žฅ๋„ ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ

echo " Updating repository metadata"
apt-get -qq update

# Install PHP with dependencies and NGINX Unit
echo " Installing PHP, NGINX Unit, NGINX, Certbot, and MariaDB"
apt-get -qq install -y --no-install-recommends 
  certbot 
  python3-certbot-nginx 
  php-cli 
  php-common 
  php-bcmath 
  php-curl 
  php-gd 
  php-imagick 
  php-mbstring 
  php-mysql 
  php-opcache 
  php-xml 
  php-zip 
  ghostscript 
  nginx 
  unit 
  unit-php 
  mariadb-server

NGINX ์œ ๋‹› ๋ฐ WordPress์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•  PHP ์„ค์ •

์Šคํฌ๋ฆฝํŠธ๋Š” ๋””๋ ‰ํ„ฐ๋ฆฌ์— ์„ค์ • ํŒŒ์ผ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. conf.d. ์ด๋Š” PHP์˜ ์ตœ๋Œ€ ํŒŒ์ผ ์—…๋กœ๋“œ ํฌ๊ธฐ๋ฅผ ์„ค์ •ํ•˜๊ณ , PHP ์˜ค๋ฅ˜๋ฅผ STDERR๋กœ ์ถœ๋ ฅํ•˜์—ฌ NGINX ์žฅ์น˜์— ๊ธฐ๋ก๋˜๊ณ  NGINX ์žฅ์น˜๋ฅผ ๋‹ค์‹œ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ

# Find the major and minor PHP version so that we can write to its conf.d directory
PHP_MAJOR_MINOR_VERSION="$(php -v | head -n1 | cut -d' ' -f2 | cut -d'.' -f1,2)"

if [ ! -f "/etc/php/${PHP_MAJOR_MINOR_VERSION}/embed/conf.d/30-wordpress-overrides.ini" ]; then
  echo " Configuring PHP for use with NGINX Unit and WordPress"
  # Add PHP configuration overrides
  cat > "/etc/php/${PHP_MAJOR_MINOR_VERSION}/embed/conf.d/30-wordpress-overrides.ini" << EOM
; Set a larger maximum upload size so that WordPress can handle
; bigger media files.
upload_max_filesize=${UPLOAD_MAX_FILESIZE}
post_max_size=${UPLOAD_MAX_FILESIZE}
; Write error log to STDERR so that error messages show up in the NGINX Unit log
error_log=/dev/stderr
EOM
fi

# Restart NGINX Unit because we have reconfigured PHP
echo " Restarting NGINX Unit"
service unit restart

WordPress์šฉ MariaDB ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์„ค์ • ์ง€์ •

์šฐ๋ฆฌ๋Š” MySQL ๋Œ€์‹  MariaDB๋ฅผ ์„ ํƒํ–ˆ์Šต๋‹ˆ๋‹ค. ์™œ๋ƒํ•˜๋ฉด ์ปค๋ฎค๋‹ˆํ‹ฐ ํ™œ๋™์ด ๋” ๋งŽ๊ณ  ๊ธฐ๋ณธ์ ์œผ๋กœ ๋” ๋‚˜์€ ์„ฑ๋Šฅ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. (์•„๋งˆ๋„ ์—ฌ๊ธฐ์—์„œ๋Š” ๋ชจ๋“  ๊ฒƒ์ด ๋” ๊ฐ„๋‹จํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค. MySQL์„ ์„ค์น˜ํ•˜๋ ค๋ฉด ๋‹ค๋ฅธ ์ €์žฅ์†Œ๋ฅผ ์ถ”๊ฐ€ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค., ์•ฝ. ์—ญ์ž).

์Šคํฌ๋ฆฝํŠธ๋Š” ์ƒˆ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ๋ฃจํ”„๋ฐฑ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํ†ตํ•ด WordPress ์•ก์„ธ์Šค ์ž๊ฒฉ ์ฆ๋ช…์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ

# Set up the WordPress database
echo " Configuring MariaDB for WordPress"
mysqladmin create wordpress || echo "Ignoring above error because database may already exist"
mysql -e "GRANT ALL PRIVILEGES ON wordpress.* TO "wordpress"@"localhost" IDENTIFIED BY "$WORDPRESS_DB_PASSWORD"; FLUSH PRIVILEGES;"

WordPress CLI ํ”„๋กœ๊ทธ๋žจ ์„ค์น˜

์ด ๋‹จ๊ณ„์—์„œ ์Šคํฌ๋ฆฝํŠธ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค. WP-CLI. ์ด๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ํŒŒ์ผ์„ ์ˆ˜๋™์œผ๋กœ ํŽธ์ง‘ํ•˜๊ฑฐ๋‚˜ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ์—…๋ฐ์ดํŠธํ•˜๊ฑฐ๋‚˜ ์ œ์–ดํŒ์— ๋กœ๊ทธ์ธํ•˜์ง€ ์•Š๊ณ ๋„ WordPress ์„ค์ •์„ ์„ค์น˜ํ•˜๊ณ  ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ…Œ๋งˆ์™€ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ์„ ์„ค์น˜ํ•˜๊ณ  WordPress๋ฅผ ์—…๋ฐ์ดํŠธํ•˜๋Š” ๋ฐ์—๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ

if [ ! -f /usr/local/bin/wp ]; then
  # Install the WordPress CLI
  echo " Installing the WordPress CLI tool"
  curl --retry 6 -Ls "https://github.com/wp-cli/wp-cli/releases/download/v${WORDPRESS_CLI_VERSION}/wp-cli-${WORDPRESS_CLI_VERSION}.phar" > /usr/local/bin/wp
  echo "$WORDPRESS_CLI_MD5 /usr/local/bin/wp" | md5sum -c -
  chmod +x /usr/local/bin/wp
fi

WordPress ์„ค์น˜ ๋ฐ ๊ตฌ์„ฑ

์Šคํฌ๋ฆฝํŠธ๋Š” ์ตœ์‹  ๋ฒ„์ „์˜ WordPress๋ฅผ ๋””๋ ‰ํ† ๋ฆฌ์— ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค. /var/www/wordpress, ๋˜ํ•œ ์„ค์ •์„ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.

  • ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์—ฐ๊ฒฐ์€ TCP ํŠธ๋ž˜ํ”ฝ์„ ์ค„์ด๊ธฐ ์œ„ํ•ด ๋ฃจํ”„๋ฐฑ ์‹œ TCP ๋Œ€์‹  Unix ๋„๋ฉ”์ธ ์†Œ์ผ“์„ ํ†ตํ•ด ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.
  • WordPress์— ์ ‘๋‘์‚ฌ ์ถ”๊ฐ€ https:// ํด๋ผ์ด์–ธํŠธ๊ฐ€ HTTPS๋ฅผ ํ†ตํ•ด NGINX์— ์—ฐ๊ฒฐํ•˜๋Š” ๊ฒฝ์šฐ URL์— ์—ฐ๊ฒฐํ•˜๊ณ  ์›๊ฒฉ ํ˜ธ์ŠคํŠธ ์ด๋ฆ„(NGINX์—์„œ ์ œ๊ณตํ•œ ๋Œ€๋กœ)์„ PHP๋กœ ๋ณด๋ƒ…๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ์ด๊ฒƒ์„ ์„ค์ •ํ•˜๊ธฐ ์œ„ํ•ด ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
  • WordPress์— ๋กœ๊ทธ์ธํ•˜๋ ค๋ฉด HTTPS๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
  • URL ๊ตฌ์กฐ๋Š” ์ž๋™์œผ๋กœ ๋ฆฌ์†Œ์Šค ๊ธฐ๋ฐ˜์ž…๋‹ˆ๋‹ค.
  • WordPress ๋””๋ ‰ํ„ฐ๋ฆฌ์— ๋Œ€ํ•ด ์˜ฌ๋ฐ”๋ฅธ ํŒŒ์ผ ์‹œ์Šคํ…œ ๊ถŒํ•œ์ด ์„ค์ •๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ

if [ ! -d /var/www/wordpress ]; then
  # Create WordPress directories
  mkdir -p /var/www/wordpress
  chown -R www-data:www-data /var/www

  # Download WordPress using the WordPress CLI
  echo " Installing WordPress"
  su -s /bin/sh -c 'wp --path=/var/www/wordpress core download' www-data

  WP_CONFIG_CREATE_CMD="wp --path=/var/www/wordpress config create --extra-php --dbname=wordpress --dbuser=wordpress --dbhost="localhost:/var/run/mysqld/mysqld.sock" --dbpass="${WORDPRESS_DB_PASSWORD}""

  # This snippet is injected into the wp-config.php file when it is created;
  # it informs WordPress that we are behind a reverse proxy and as such
  # allows it to generate links using HTTPS
  cat > /tmp/wp_forwarded_for.php << 'EOM'
/* Turn HTTPS 'on' if HTTP_X_FORWARDED_PROTO matches 'https' */
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {
    $_SERVER['HTTPS'] = 'on';
}
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
    $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}
EOM

  # Create WordPress configuration
  su -s /bin/sh -p -c "cat /tmp/wp_forwarded_for.php | ${WP_CONFIG_CREATE_CMD}" www-data
  rm /tmp/wp_forwarded_for.php
  su -s /bin/sh -p -c "wp --path=/var/www/wordpress config set 'FORCE_SSL_ADMIN' 'true'" www-data

  # Install WordPress
  WP_SITE_INSTALL_CMD="wp --path=/var/www/wordpress core install --url="${WORDPRESS_URL}" --title="${WORDPRESS_SITE_TITLE}" --admin_user="${WORDPRESS_ADMIN_USER}" --admin_password="${WORDPRESS_ADMIN_PASSWORD}" --admin_email="${WORDPRESS_ADMIN_EMAIL}" --skip-email"
  su -s /bin/sh -p -c "${WP_SITE_INSTALL_CMD}" www-data

  # Set permalink structure to a sensible default that isn't in the UI
  su -s /bin/sh -p -c "wp --path=/var/www/wordpress option update permalink_structure '/%year%/%monthnum%/%postname%/'" www-data

  # Remove sample file because it is cruft and could be a security problem
  rm /var/www/wordpress/wp-config-sample.php

  # Ensure that WordPress permissions are correct
  find /var/www/wordpress -type d -exec chmod g+s {} ;
  chmod g+w /var/www/wordpress/wp-content
  chmod -R g+w /var/www/wordpress/wp-content/themes
  chmod -R g+w /var/www/wordpress/wp-content/plugins
fi

NGINX ์žฅ์น˜ ์„ค์ •

์ด ์Šคํฌ๋ฆฝํŠธ๋Š” PHP๋ฅผ ์‹คํ–‰ํ•˜๊ณ  WordPress ๊ฒฝ๋กœ๋ฅผ ์ฒ˜๋ฆฌํ•˜๋„๋ก NGINX ์œ ๋‹›์„ ๊ตฌ์„ฑํ•˜์—ฌ PHP ํ”„๋กœ์„ธ์Šค์˜ ๋„ค์ž„์ŠคํŽ˜์ด์Šค๋ฅผ ๊ฒฉ๋ฆฌํ•˜๊ณ  ์„ฑ๋Šฅ ์„ค์ •์„ ์ตœ์ ํ™”ํ•ฉ๋‹ˆ๋‹ค. ์ฃผ๋ชฉํ• ๋งŒํ•œ ์„ธ ๊ฐ€์ง€ ๊ธฐ๋Šฅ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

  • ๋„ค์ž„์ŠคํŽ˜์ด์Šค ์ง€์›์€ ์Šคํฌ๋ฆฝํŠธ๊ฐ€ ์ปจํ…Œ์ด๋„ˆ์—์„œ ์‹คํ–‰ ์ค‘์ธ์ง€ ํ™•์ธํ•˜๋Š” ์กฐ๊ฑด์— ๋”ฐ๋ผ ๊ฒฐ์ •๋ฉ๋‹ˆ๋‹ค. ์ด๋Š” ๋Œ€๋ถ€๋ถ„์˜ ์ปจํ…Œ์ด๋„ˆ ์„ค์ •์ด ์ปจํ…Œ์ด๋„ˆ์˜ ์ค‘์ฒฉ ์‹คํ–‰์„ ์ง€์›ํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
  • ๋„ค์ž„์ŠคํŽ˜์ด์Šค์— ๋Œ€ํ•œ ์ง€์›์ด ์žˆ์œผ๋ฉด ๋„ค์ž„์ŠคํŽ˜์ด์Šค๊ฐ€ ๋น„ํ™œ์„ฑํ™”๋ฉ๋‹ˆ๋‹ค. ๋„คํŠธ์›Œํฌ. ์ด๋Š” WordPress๊ฐ€ ์—”๋“œํฌ์ธํŠธ์— ๋™์‹œ์— ์—ฐ๊ฒฐํ•˜๊ณ  ์ธํ„ฐ๋„ท์—์„œ ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ๋ฐ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
  • ์ตœ๋Œ€ ํ”„๋กœ์„ธ์Šค ์ˆ˜๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ฒฐ์ •๋ฉ๋‹ˆ๋‹ค. (MariaDB ๋ฐ NGINX Uniy๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ฉ”๋ชจ๋ฆฌ)/(PHP์˜ RAM ์ œํ•œ + 5)
    ์ด ๊ฐ’์€ NGINX ๋‹จ์œ„ ์„ค์ •์—์„œ ์„ค์ •๋ฉ๋‹ˆ๋‹ค.

๋˜ํ•œ ์ด ๊ฐ’์€ ํ•ญ์ƒ ์ตœ์†Œ ๋‘ ๊ฐœ์˜ PHP ํ”„๋กœ์„ธ์Šค๊ฐ€ ์‹คํ–‰๋˜๊ณ  ์žˆ์Œ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” WordPress๊ฐ€ ์ž์ฒด์ ์œผ๋กœ ๋งŽ์€ ๋น„๋™๊ธฐ ์š”์ฒญ์„ ํ•˜๊ณ  ์ถ”๊ฐ€ ํ”„๋กœ์„ธ์Šค๊ฐ€ ์‹คํ–‰๋˜์ง€ ์•Š์œผ๋ฉด WP-Cron์ด ์ค‘๋‹จ๋˜๊ธฐ ๋•Œ๋ฌธ์— ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์—์„œ ์ƒ์„ฑ๋œ ์„ค์ •์€ ๋ณด์ˆ˜์ ์ด๋ฏ€๋กœ ๋กœ์ปฌ ์„ค์ •์— ๋”ฐ๋ผ ์ด๋Ÿฌํ•œ ์ œํ•œ์„ ๋Š˜๋ฆฌ๊ฑฐ๋‚˜ ์ค„์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋Œ€๋ถ€๋ถ„์˜ ํ”„๋กœ๋•์…˜ ์‹œ์Šคํ…œ์—์„œ ์„ค์ •์€ 10์—์„œ 100 ์‚ฌ์ด์ž…๋‹ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ

if [ "${container:-unknown}" != "lxc" ] && [ "$(grep -m1 -a container=lxc /proc/1/environ | tr -d '')" == "" ]; then
  NAMESPACES='"namespaces": {
        "cgroup": true,
        "credential": true,
        "mount": true,
        "network": false,
        "pid": true,
        "uname": true
    }'
else
  NAMESPACES='"namespaces": {}'
fi

PHP_MEM_LIMIT="$(grep 'memory_limit' /etc/php/7.4/embed/php.ini | tr -d ' ' | cut -f2 -d= | numfmt --from=iec)"
AVAIL_MEM="$(grep MemAvailable /proc/meminfo | tr -d ' kB' | cut -f2 -d: | numfmt --from-unit=K)"
MAX_PHP_PROCESSES="$(echo "${AVAIL_MEM}/${PHP_MEM_LIMIT}+5" | bc)"
echo " Calculated the maximum number of PHP processes as ${MAX_PHP_PROCESSES}. You may want to tune this value due to variations in your configuration. It is not unusual to see values between 10-100 in production configurations."

echo " Configuring NGINX Unit to use PHP and WordPress"
cat > /tmp/wordpress.json << EOM
{
  "settings": {
    "http": {
      "header_read_timeout": 30,
      "body_read_timeout": 30,
      "send_timeout": 30,
      "idle_timeout": 180,
      "max_body_size": $(numfmt --from=iec ${UPLOAD_MAX_FILESIZE})
    }
  },
  "listeners": {
    "127.0.0.1:8080": {
      "pass": "routes/wordpress"
    }
  },
  "routes": {
    "wordpress": [
      {
        "match": {
          "uri": [
            "*.php",
            "*.php/*",
            "/wp-admin/"
          ]
        },
        "action": {
          "pass": "applications/wordpress/direct"
        }
      },
      {
        "action": {
          "share": "/var/www/wordpress",
          "fallback": {
            "pass": "applications/wordpress/index"
          }
        }
      }
    ]
  },
  "applications": {
    "wordpress": {
      "type": "php",
      "user": "www-data",
      "group": "www-data",
      "processes": {
        "max": ${MAX_PHP_PROCESSES},
        "spare": 1
      },
      "isolation": {
        ${NAMESPACES}
      },
      "targets": {
        "direct": {
          "root": "/var/www/wordpress/"
        },
        "index": {
          "root": "/var/www/wordpress/",
          "script": "index.php"
        }
      }
    }
  }
}
EOM

curl -X PUT --data-binary @/tmp/wordpress.json --unix-socket /run/control.unit.sock http://localhost/config

NGINX ์„ค์ •

๊ธฐ๋ณธ NGINX ์„ค์ • ๊ตฌ์„ฑ

์Šคํฌ๋ฆฝํŠธ๋Š” NGINX ์บ์‹œ์šฉ ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ์ƒ์„ฑํ•œ ๋‹ค์Œ ๊ธฐ๋ณธ ๊ตฌ์„ฑ ํŒŒ์ผ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. nginx.conf. ํ•ธ๋“ค๋Ÿฌ ํ”„๋กœ์„ธ์Šค ์ˆ˜์™€ ๋‹ค์šด๋กœ๋“œํ•  ์ˆ˜ ์žˆ๋Š” ์ตœ๋Œ€ ํŒŒ์ผ ํฌ๊ธฐ ์„ค์ •์— ์ฃผ์˜ํ•˜์„ธ์š”. ๋‹ค์Œ ์„น์…˜์—์„œ ์ •์˜ํ•  ์••์ถ• ์„ค์ • ํŒŒ์ผ์ด ์—ฐ๊ฒฐ๋˜๊ณ  ์บ์‹ฑ ์„ค์ •์ด ์ด์–ด์ง€๋Š” ์ค„๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ

# Make directory for NGINX cache
mkdir -p /var/cache/nginx/proxy

echo " Configuring NGINX"
cat > ${NGINX_CONF_DIR}/nginx.conf << EOM
user nginx;
worker_processes auto;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       ${NGINX_CONF_DIR}/mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    client_max_body_size ${UPLOAD_MAX_FILESIZE};
    keepalive_timeout  65;
    # gzip settings
    include ${NGINX_CONF_DIR}/gzip_compression.conf;
    # Cache settings
    proxy_cache_path /var/cache/nginx/proxy
        levels=1:2
        keys_zone=wp_cache:10m
        max_size=10g
        inactive=60m
        use_temp_path=off;
    include ${NGINX_CONF_DIR}/conf.d/*.conf;
}
EOM

NGINX ์••์ถ• ์„ค์ •

์ฝ˜ํ…์ธ ๋ฅผ ํด๋ผ์ด์–ธํŠธ์— ๋ณด๋‚ด๊ธฐ ์ „์— ์ฆ‰์‹œ ์••์ถ•ํ•˜๋Š” ๊ฒƒ์€ ์‚ฌ์ดํŠธ ์„ฑ๋Šฅ์„ ํ–ฅ์ƒ์‹œํ‚ค๋Š” ์ข‹์€ ๋ฐฉ๋ฒ•์ด์ง€๋งŒ ์••์ถ•์ด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๊ตฌ์„ฑ๋œ ๊ฒฝ์šฐ์—๋งŒ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ์Šคํฌ๋ฆฝํŠธ์˜ ์ด ์„น์…˜์€ ์„ค์ •์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ.

์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ

cat > ${NGINX_CONF_DIR}/gzip_compression.conf << 'EOM'
# Credit: https://github.com/h5bp/server-configs-nginx/
# ----------------------------------------------------------------------
# | Compression                                                        |
# ----------------------------------------------------------------------
# https://nginx.org/en/docs/http/ngx_http_gzip_module.html
# Enable gzip compression.
# Default: off
gzip on;
# Compression level (1-9).
# 5 is a perfect compromise between size and CPU usage, offering about 75%
# reduction for most ASCII files (almost identical to level 9).
# Default: 1
gzip_comp_level 6;
# Don't compress anything that's already small and unlikely to shrink much if at
# all (the default is 20 bytes, which is bad as that usually leads to larger
# files after gzipping).
# Default: 20
gzip_min_length 256;
# Compress data even for clients that are connecting to us via proxies,
# identified by the "Via" header (required for CloudFront).
# Default: off
gzip_proxied any;
# Tell proxies to cache both the gzipped and regular version of a resource
# whenever the client's Accept-Encoding capabilities header varies;
# Avoids the issue where a non-gzip capable client (which is extremely rare
# today) would display gibberish if their proxy gave them the gzipped version.
# Default: off
gzip_vary on;
# Compress all output labeled with one of the following MIME-types.
# `text/html` is always compressed by gzip module.
# Default: text/html
gzip_types
  application/atom+xml
  application/geo+json
  application/javascript
  application/x-javascript
  application/json
  application/ld+json
  application/manifest+json
  application/rdf+xml
  application/rss+xml
  application/vnd.ms-fontobject
  application/wasm
  application/x-web-app-manifest+json
  application/xhtml+xml
  application/xml
  font/eot
  font/otf
  font/ttf
  image/bmp
  image/svg+xml
  text/cache-manifest
  text/calendar
  text/css
  text/javascript
  text/markdown
  text/plain
  text/xml
  text/vcard
  text/vnd.rim.location.xloc
  text/vtt
  text/x-component
  text/x-cross-domain-policy;
EOM

WordPress์šฉ NGINX ์„ค์ •

๋‹ค์Œ์œผ๋กœ ์Šคํฌ๋ฆฝํŠธ๋Š” WordPress์šฉ ๊ตฌ์„ฑ ํŒŒ์ผ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. default.conf ์นดํƒˆ๋กœ๊ทธ์— conf.d. ์—ฌ๊ธฐ์—์„œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ตฌ์„ฑ๋ฉ๋‹ˆ๋‹ค.

  • Certbot์„ ํ†ตํ•ด Let's Encrypt์—์„œ ๋ฐ›์€ TLS ์ธ์ฆ์„œ ํ™œ์„ฑํ™”(๊ตฌ์„ฑ์€ ๋‹ค์Œ ์„น์…˜์—์„œ ์ง„ํ–‰๋ฉ๋‹ˆ๋‹ค)
  • Let's Encrypt์˜ ๊ถŒ์žฅ ์‚ฌํ•ญ์„ ๊ธฐ๋ฐ˜์œผ๋กœ TLS ๋ณด์•ˆ ์„ค์ • ๊ตฌ์„ฑ
  • ๊ธฐ๋ณธ์ ์œผ๋กœ ๊ฑด๋„ˆ๋›ด ์š”์ฒญ ์บ์‹ฑ์„ 1์‹œ๊ฐ„ ๋™์•ˆ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค.
  • ์ผ๋ฐ˜์ ์œผ๋กœ ์š”์ฒญ๋˜๋Š” ๋‘ ๊ฐ€์ง€ ํŒŒ์ผ์ธ favicon.ico ๋ฐ robots.txt์— ๋Œ€ํ•ด ์•ก์„ธ์Šค ๋กœ๊น…๊ณผ ํŒŒ์ผ์„ ์ฐพ์„ ์ˆ˜ ์—†๋Š” ๊ฒฝ์šฐ ์˜ค๋ฅ˜ ๋กœ๊น…์„ ๋น„ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค.
  • ์ˆจ๊ฒจ์ง„ ํŒŒ์ผ ๋ฐ ์ผ๋ถ€ ํŒŒ์ผ์— ๋Œ€ํ•œ ์•ก์„ธ์Šค ๊ฑฐ๋ถ€ . PHP๋Š”๋ถˆ๋ฒ•์ ์ธ ์ ‘์†์ด๋‚˜ ์˜๋„ํ•˜์ง€ ์•Š์€ ์‹คํ–‰์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด
  • ์ •์  ๋ฐ ๊ธ€๊ผด ํŒŒ์ผ์— ๋Œ€ํ•œ ์•ก์„ธ์Šค ๋กœ๊น… ๋น„ํ™œ์„ฑํ™”
  • ์ œ๋ชฉ ์„ค์ • ์•ก์„ธ์Šค ์ œ์–ด ํ—ˆ์šฉ ์ถœ์ฒ˜ ๊ธ€๊ผด ํŒŒ์ผ์˜ ๊ฒฝ์šฐ
  • index.php ๋ฐ ๊ธฐํƒ€ ํ†ต๊ณ„์— ๋Œ€ํ•œ ๋ผ์šฐํŒ…์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ

cat > ${NGINX_CONF_DIR}/conf.d/default.conf << EOM
upstream unit_php_upstream {
    server 127.0.0.1:8080;
    keepalive 32;
}
server {
    listen 80;
    listen [::]:80;
    # ACME-challenge used by Certbot for Let's Encrypt
    location ^~ /.well-known/acme-challenge/ {
      root /var/www/certbot;
    }
    location / {
      return 301 https://${TLS_HOSTNAME}$request_uri;
    }
}
server {
    listen      443 ssl http2;
    listen [::]:443 ssl http2;
    server_name ${TLS_HOSTNAME};
    root        /var/www/wordpress/;
    # Let's Encrypt configuration
    ssl_certificate         ${CERT_DIR}/fullchain.pem;
    ssl_certificate_key     ${CERT_DIR}/privkey.pem;
    ssl_trusted_certificate ${CERT_DIR}/chain.pem;
    include ${NGINX_CONF_DIR}/options-ssl-nginx.conf;
    ssl_dhparam ${NGINX_CONF_DIR}/ssl-dhparams.pem;
    # OCSP stapling
    ssl_stapling on;
    ssl_stapling_verify on;
    # Proxy caching
    proxy_cache wp_cache;
    proxy_cache_valid 200 302 1h;
    proxy_cache_valid 404 1m;
    proxy_cache_revalidate on;
    proxy_cache_background_update on;
    proxy_cache_lock on;
    proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # Deny all attempts to access hidden files such as .htaccess, .htpasswd,
    # .DS_Store (Mac)
    # Keep logging the requests to parse later (or to pass to firewall utilities
    # such as fail2ban)
    location ~ /. {
        deny all;
    }
    # Deny access to any files with a .php extension in the uploads directory;
    # works in subdirectory installs and also in multi-site network.
    # Keep logging the requests to parse later (or to pass to firewall utilities
    # such as fail2ban).
    location ~* /(?:uploads|files)/.*.php$ {
        deny all;
    }
    # WordPress: deny access to wp-content, wp-includes PHP files
    location ~* ^/(?:wp-content|wp-includes)/.*.php$ {
        deny all;
    }
    # Deny public access to wp-config.php
    location ~* wp-config.php {
        deny all;
    }
    # Do not log access for static assets, media
    location ~* .(?:css(.map)?|js(.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
        access_log off;
    }
    location ~* .(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
        add_header Access-Control-Allow-Origin "*";
        access_log off;
    }
    location / {
        try_files $uri @index_php;
    }
    location @index_php {
        proxy_socket_keepalive on;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_pass       http://unit_php_upstream;
    }
    location ~* .php$ {
        proxy_socket_keepalive on;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        try_files        $uri =404;
        proxy_pass       http://unit_php_upstream;
    }
}
EOM

Let's Encrypt ์ธ์ฆ์„œ๋ฅผ ์œ„ํ•œ Certbot ๊ตฌ์„ฑ ๋ฐ ์ž๋™ ๊ฐฑ์‹ 

Certbot Let's Encrypt์—์„œ TLS ์ธ์ฆ์„œ๋ฅผ ํš๋“ํ•˜๊ณ  ์ž๋™์œผ๋กœ ๊ฐฑ์‹ ํ•  ์ˆ˜ ์žˆ๋Š” EFF(Electronic Frontier Foundation)์˜ ๋ฌด๋ฃŒ ๋„๊ตฌ์ž…๋‹ˆ๋‹ค. ์Šคํฌ๋ฆฝํŠธ๋Š” ๋‹ค์Œ ๋‹จ๊ณ„๋ฅผ ์ˆ˜ํ–‰ํ•˜์—ฌ NGINX์—์„œ Let's Encrypt์˜ ์ธ์ฆ์„œ๋ฅผ ์ฒ˜๋ฆฌํ•˜๋„๋ก Certbot์„ ๊ตฌ์„ฑํ•ฉ๋‹ˆ๋‹ค.

  • NGINX๋ฅผ ์ค‘์ง€ํ•ฉ๋‹ˆ๋‹ค.
  • ๊ถŒ์žฅ TLS ์„ค์ • ๋‹ค์šด๋กœ๋“œ
  • Certbot์„ ์‹คํ–‰ํ•˜์—ฌ ์‚ฌ์ดํŠธ์— ๋Œ€ํ•œ ์ธ์ฆ์„œ๋ฅผ ์–ป์Šต๋‹ˆ๋‹ค.
  • ์ธ์ฆ์„œ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด NGINX๋ฅผ ๋‹ค์‹œ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.
  • ๋งค์ผ ์˜ค์ „ 3์‹œ 24๋ถ„์— ์‹คํ–‰๋˜๋„๋ก Certbot์„ ๊ตฌ์„ฑํ•˜์—ฌ ์ธ์ฆ์„œ๋ฅผ ์—…๋ฐ์ดํŠธํ•ด์•ผ ํ•˜๋Š”์ง€ ํ™•์ธํ•˜๊ณ  ํ•„์š”ํ•œ ๊ฒฝ์šฐ ์ƒˆ ์ธ์ฆ์„œ๋ฅผ ๋‹ค์šด๋กœ๋“œํ•˜๊ณ  NGINX๋ฅผ ๋‹ค์‹œ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ

echo " Stopping NGINX in order to set up Let's Encrypt"
service nginx stop

mkdir -p /var/www/certbot
chown www-data:www-data /var/www/certbot
chmod g+s /var/www/certbot

if [ ! -f ${NGINX_CONF_DIR}/options-ssl-nginx.conf ]; then
  echo " Downloading recommended TLS parameters"
  curl --retry 6 -Ls -z "Tue, 14 Apr 2020 16:36:07 GMT" 
    -o "${NGINX_CONF_DIR}/options-ssl-nginx.conf" 
    "https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/_internal/tls_configs/options-ssl-nginx.conf" 
    || echo "Couldn't download latest options-ssl-nginx.conf"
fi

if [ ! -f ${NGINX_CONF_DIR}/ssl-dhparams.pem ]; then
  echo " Downloading recommended TLS DH parameters"
  curl --retry 6 -Ls -z "Tue, 14 Apr 2020 16:49:18 GMT" 
    -o "${NGINX_CONF_DIR}/ssl-dhparams.pem" 
    "https://raw.githubusercontent.com/certbot/certbot/master/certbot/certbot/ssl-dhparams.pem" 
    || echo "Couldn't download latest ssl-dhparams.pem"
fi

# If tls_certs_init.sh hasn't been run before, remove the self-signed certs
if [ ! -d "/etc/letsencrypt/accounts" ]; then
  echo " Removing self-signed certificates"
  rm -rf "${CERT_DIR}"
fi

if [ "" = "${LETS_ENCRYPT_STAGING:-}" ] || [ "0" = "${LETS_ENCRYPT_STAGING}" ]; then
  CERTBOT_STAGING_FLAG=""
else
  CERTBOT_STAGING_FLAG="--staging"
fi

if [ ! -f "${CERT_DIR}/fullchain.pem" ]; then
  echo " Generating certificates with Let's Encrypt"
  certbot certonly --standalone 
         -m "${WORDPRESS_ADMIN_EMAIL}" 
         ${CERTBOT_STAGING_FLAG} 
         --agree-tos --force-renewal --non-interactive 
         -d "${TLS_HOSTNAME}"
fi

echo " Starting NGINX in order to use new configuration"
service nginx start

# Write crontab for periodic Let's Encrypt cert renewal
if [ "$(crontab -l | grep -m1 'certbot renew')" == "" ]; then
  echo " Adding certbot to crontab for automatic Let's Encrypt renewal"
  (crontab -l 2>/dev/null; echo "24 3 * * * certbot renew --nginx --post-hook 'service nginx reload'") | crontab -
fi

์‚ฌ์ดํŠธ์˜ ์ถ”๊ฐ€ ์‚ฌ์šฉ์ž ์ •์˜

์šฐ๋ฆฌ๋Š” TLSSSL์ด ํ™œ์„ฑํ™”๋œ ํ”„๋กœ๋•์…˜ ์ง€์› ์›น์‚ฌ์ดํŠธ๋ฅผ ์ œ๊ณตํ•˜๊ธฐ ์œ„ํ•ด ์Šคํฌ๋ฆฝํŠธ๊ฐ€ NGINX ๋ฐ NGINX ์œ ๋‹›์„ ๊ตฌ์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์œ„์—์„œ ์ด์•ผ๊ธฐํ–ˆ์Šต๋‹ˆ๋‹ค. ํ•„์š”์— ๋”ฐ๋ผ ๋‚˜์ค‘์— ๋‹ค์Œ์„ ์ถ”๊ฐ€ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

  • ์ง€์› ๋ธŒ๋กœ ํ‹€๋ฆฌ, HTTPS๋ฅผ ํ†ตํ•œ ํ–ฅ์ƒ๋œ ์‹ค์‹œ๊ฐ„ ์••์ถ•
  • ModSecurity๋ฅผ ั WordPress์˜ ๊ทœ์น™์‚ฌ์ดํŠธ์— ๋Œ€ํ•œ ์ž๋™ํ™”๋œ ๊ณต๊ฒฉ์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด
  • ๋ฐฑ์—… ๊ท€ํ•˜์—๊ฒŒ ์ ํ•ฉํ•œ WordPress์šฉ
  • ๋ณดํ˜ธ ๋ฅผ ํ†ตํ•ด AppArmor (์šฐ๋ถ„ํˆฌ์—์„œ)
  • WordPress์—์„œ ๋ฉ”์ผ์„ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋„๋ก Postfix ๋˜๋Š” msmtp
  • ์‚ฌ์ดํŠธ์—์„œ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” ํŠธ๋ž˜ํ”ฝ ์–‘์„ ํŒŒ์•…ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์ดํŠธ๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

๋” ๋‚˜์€ ์‚ฌ์ดํŠธ ์„ฑ๋Šฅ์„ ์œ„ํ•ด์„œ๋Š” ๋‹ค์Œ์œผ๋กœ ์—…๊ทธ๋ ˆ์ด๋“œํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. NGINX ํ”Œ๋Ÿฌ์Šค, ์˜คํ”ˆ ์†Œ์Šค NGINX๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•œ ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ๊ธ‰ ์ƒ์šฉ ์ œํ’ˆ์ž…๋‹ˆ๋‹ค. ๊ตฌ๋…์ž๋Š” ๋™์ ์œผ๋กœ ๋กœ๋“œ๋œ Brotli ๋ชจ๋“ˆ์„ ๋ฐ›๊ฒŒ ๋˜๋ฉฐ (์ถ”๊ฐ€ ๋น„์šฉ ๋ฐœ์ƒ) NGINX ModSecurity WAF. ์šฐ๋ฆฌ๋Š” ๋˜ํ•œ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค NGINX ์•ฑ ๋ณดํ˜ธ, F5์˜ ์—…๊ณ„ ์ตœ๊ณ ์˜ ๋ณด์•ˆ ๊ธฐ์ˆ ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•˜๋Š” NGINX Plus์šฉ WAF ๋ชจ๋“ˆ์ž…๋‹ˆ๋‹ค.

NB ๋กœ๋“œ๊ฐ€ ๋งŽ์€ ์›น์‚ฌ์ดํŠธ์— ๋Œ€ํ•œ ์ง€์›์„ ๋ฐ›์œผ๋ ค๋ฉด ์ „๋ฌธ๊ฐ€์—๊ฒŒ ๋ฌธ์˜ํ•˜์„ธ์š”. ์‚ฌ์šฐ์Šค ๋ธŒ๋ฆฌ์ง€. ์šฐ๋ฆฌ๋Š” ์–ด๋–ค ๋ถ€ํ•˜์—์„œ๋„ ๊ท€ํ•˜์˜ ์›น์‚ฌ์ดํŠธ๋‚˜ ์„œ๋น„์Šค๊ฐ€ ๋น ๋ฅด๊ณ  ์•ˆ์ •์ ์œผ๋กœ ์ž‘๋™ํ•˜๋„๋ก ๋ณด์žฅํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

์ถœ์ฒ˜ : habr.com