Search

๋ฉ€ํ‹ฐ ๋„๋ฉ”์ธ

๋ฉ€ํ‹ฐ๋„๋ฉ”์ธ ์„ค์ • (Multi-Domain Configuration)

๊ฐœ์š”

๋ฉ€ํ‹ฐ๋„๋ฉ”์ธ์ด๋ž€ Nginx ํ•˜๋‚˜์—์„œ ์™„์ „ํžˆ ๋‹ค๋ฅธ ์—ฌ๋Ÿฌ ๋„๋ฉ”์ธ์„ ๋™์‹œ์— ์ฒ˜๋ฆฌํ•˜๋Š” ๊ฒƒ์„ ๋งํ•œ๋‹ค. example.com๊ณผ myproject.com, ๊ทธ๋ฆฌ๊ณ  anothersite.io ๊ฐ™์€ ์ „ํ˜€ ๋‹ค๋ฅธ ๋„๋ฉ”์ธ๋“ค์„ ํ•œ ์„œ๋ฒ„์—์„œ ๋ชจ๋‘ ๊ด€๋ฆฌํ•˜๋Š” ๊ฑฐ์•ผ.
๋งˆ์น˜ ๋นŒ๋”ฉ ๊ด€๋ฆฌ์ธ์ฒ˜๋Ÿผ ์ƒ๊ฐํ•ด๋ณด์ž. ํ•œ ๋ช…์˜ ๋นŒ๋”ฉ ๊ด€๋ฆฌ์ธ์ด ์—ฌ๋Ÿฌ ๊ฑด๋ฌผ์„ ๊ด€๋ฆฌํ•˜๋Š” ๊ฑฐ๋‹ˆ๊นŒ, example.com ๊ฑด๋ฌผ ๋ฐฉ๋ฌธ๊ฐ์€ 1๋ฒˆ ๊ฒŒ์ดํŠธ๋กœ, myproject.com ๊ฑด๋ฌผ ๋ฐฉ๋ฌธ๊ฐ์€ 2๋ฒˆ ๊ฒŒ์ดํŠธ๋กœ ๋ณด๋‚ด๋Š” ์‹์ด๋‹ค.
๋ฉ€ํ‹ฐ๋„๋ฉ”์ธ์„ ์“ฐ๋ฉด:
โ€ข
์„œ๋ฒ„ ๋น„์šฉ ์ ˆ๊ฐ (์—ฌ๋Ÿฌ ๋„๋ฉ”์ธ = 1๊ฐœ ์„œ๋ฒ„)
โ€ข
๊ด€๋ฆฌ ํŽธ์˜์„ฑ (ํ•œ ๊ณณ์—์„œ ๋ชจ๋“  ๋„๋ฉ”์ธ ๊ด€๋ฆฌ)
โ€ข
SSL ์ธ์ฆ์„œ ๋…๋ฆฝ (๊ฐ ๋„๋ฉ”์ธ๋ณ„ ์ธ์ฆ์„œ)
โ€ข
๋ฆฌ์†Œ์Šค ๊ณต์œ  (์Šคํ† ๋ฆฌ์ง€, ๋ฐฑ์—…, ๋กœ๊ทธ)

๋ฉ€ํ‹ฐ๋„๋ฉ”์ธ ๊ตฌ์กฐ

graph TD
    A["๐Ÿ–ฅ๏ธ Nginx ์„œ๋ฒ„<br/>203.0.113.10<br/>ํฌํŠธ 80, 443"]

    B["๐Ÿ‘ค Client 1<br/>example.com ์ ‘์†"] -->|"์š”์ฒญ"| A
    C["๐Ÿ‘ค Client 2<br/>myproject.com ์ ‘์†"] -->|"์š”์ฒญ"| A
    D["๐Ÿ‘ค Client 3<br/>anothersite.io ์ ‘์†"] -->|"์š”์ฒญ"| A

    A -->|"Host: example.com<br/>๋งค์นญ"| E["๐Ÿ“ Site 1<br/>/var/www/example"]
    A -->|"Host: myproject.com<br/>๋งค์นญ"| F["๐Ÿ“ Site 2<br/>/var/www/myproject"]
    A -->|"Host: anothersite.io<br/>๋งค์นญ"| G["๐Ÿ“ Site 3<br/>/var/www/anothersite"]

    style A fill:#FFD700
    style E fill:#87CEEB
    style F fill:#90EE90
    style G fill:#FFB366
Mermaid
๋ณต์‚ฌ

์„œ๋ธŒ๋„๋ฉ”์ธ vs ๋ฉ€ํ‹ฐ๋„๋ฉ”์ธ vs ๊ฒฝ๋กœ

๊ตฌ๋ถ„
๋ฉ€ํ‹ฐ๋„๋ฉ”์ธ
์„œ๋ธŒ๋„๋ฉ”์ธ
๊ฒฝ๋กœ(Path)
URL ์˜ˆ์‹œ
example.com myproject.com
api.example.com admin.example.com
example.com/api example.com/admin
๋„๋ฉ”์ธ ๊ฐœ์ˆ˜
์—ฌ๋Ÿฌ ๊ฐœ
1๊ฐœ ๋ฉ”์ธ
1๊ฐœ ๋ฉ”์ธ
DNS ์„ค์ •
๊ฐ๊ฐ ํ•„์š”
1๊ฐœ (์™€์ผ๋“œ์นด๋“œ)
ํ•„์š”์—†์Œ
์ธ์ฆ์„œ
๊ฐ๊ฐ ํ•„์š”
1๊ฐœ (์™€์ผ๋“œ์นด๋“œ)
1๊ฐœ
๊ตฌ์กฐ ๋ณต์žก๋„
๋†’์Œ
์ค‘๊ฐ„
๋‚ฎ์Œ
๋ฆฌ์†Œ์Šค ๊ณต์œ 
๊ฐ€๋Šฅ
๊ฐ€๋Šฅ
์™„์ „ ๊ณต์œ 
๋…๋ฆฝ์„ฑ
์™„์ „ ๋…๋ฆฝ
๋ฐ˜๋…๋ฆฝ
๊ด€๋ จ ๋†’์Œ

1๋‹จ๊ณ„: DNS ๋ ˆ์ฝ”๋“œ ์„ค์ •

๊ฐ ๋„๋ฉ”์ธ์ด ๊ฐ™์€ Nginx ์„œ๋ฒ„ IP๋กœ ํ–ฅํ•˜๋„๋ก ์„ค์ •ํ•œ๋‹ค.
graph LR
    A["DNS Query<br/>example.com?"] -->|"A Record<br/>203.0.113.10"| X["๐Ÿ–ฅ๏ธ Nginx Server<br/>203.0.113.10"]
    B["DNS Query<br/>myproject.com?"] -->|"A Record<br/>203.0.113.10"| X
    C["DNS Query<br/>anothersite.io?"] -->|"A Record<br/>203.0.113.10"| X

    style X fill:#FFD700
Mermaid
๋ณต์‚ฌ

๊ฐ ๋„๋ฉ”์ธ ๋“ฑ๋ก์—…์ฒด์—์„œ ์„ค์ •

example.com ๋„๋ฉ”์ธ (Namecheap, GoDaddy ๋“ฑ)
Host
Type
Value
@
A
203.0.113.10
www
A
203.0.113.10
myproject.com ๋„๋ฉ”์ธ
Host
Type
Value
@
A
203.0.113.10
www
A
203.0.113.10
anothersite.io ๋„๋ฉ”์ธ
Host
Type
Value
@
A
203.0.113.10
www
A
203.0.113.10
ํ™•์ธ:
nslookup example.com # 203.0.113.10 nslookup myproject.com # 203.0.113.10 nslookup anothersite.io # 203.0.113.10
Bash
๋ณต์‚ฌ

2๋‹จ๊ณ„: Nginx ์„ค์ •

๊ธฐ๋ณธ ๊ตฌ์กฐ

# ============================================ # ๋„๋ฉ”์ธ 1: example.com # ============================================ server { listen 80; server_name example.com www.example.com; # ๋‘˜ ๋‹ค ์ฒ˜๋ฆฌ root /var/www/example; index index.html; location / { try_files $uri $uri/ =404; } } # ============================================ # ๋„๋ฉ”์ธ 2: myproject.com # ============================================ server { listen 80; server_name myproject.com www.myproject.com; root /var/www/myproject; index index.html; location / { try_files $uri $uri/ =404; } } # ============================================ # ๋„๋ฉ”์ธ 3: anothersite.io # ============================================ server { listen 80; server_name anothersite.io www.anothersite.io; root /var/www/anothersite; index index.html; location / { try_files $uri $uri/ =404; } }
Plain Text
๋ณต์‚ฌ

www๋กœ ์ž๋™ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ

์ƒํ™ฉ 1: www ์—†๋Š” ๋„๋ฉ”์ธ์„ www ์žˆ๋Š” ๊ฑธ๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ
# example.com โ†’ www.example.com์œผ๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ server { listen 80; server_name example.com; return 301 https://www.example.com$request_uri; } # ์‹ค์ œ ์ฒ˜๋ฆฌ๋Š” www.example.com์—์„œ server { listen 80; server_name www.example.com; root /var/www/example; # ... }
Plain Text
๋ณต์‚ฌ
์ƒํ™ฉ 2: www ์žˆ๋Š” ๋„๋ฉ”์ธ์„ www ์—†๋Š” ๊ฑธ๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ
# www.example.com โ†’ example.com์œผ๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ server { listen 80; server_name www.example.com; return 301 https://example.com$request_uri; } # ์‹ค์ œ ์ฒ˜๋ฆฌ๋Š” example.com์—์„œ server { listen 80; server_name example.com; root /var/www/example; # ... }
Plain Text
๋ณต์‚ฌ

HTTPS + SSL ์ธ์ฆ์„œ

์ƒํ™ฉ๋ณ„ SSL ์„ค์ •

์ƒํ™ฉ 1: ๋„๋ฉ”์ธ๋ณ„ ๊ฐœ๋ณ„ ์ธ์ฆ์„œ
# ๊ฐ ๋„๋ฉ”์ธ๋ณ„ ์ธ์ฆ์„œ ๋ฐœ๊ธ‰ certbot certonly --standalone -d example.com -d www.example.com certbot certonly --standalone -d myproject.com -d www.myproject.com certbot certonly --standalone -d anothersite.io -d www.anothersite.io
Bash
๋ณต์‚ฌ
Nginx ์„ค์ •:
server { listen 443 ssl http2; server_name example.com www.example.com; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; } server { listen 443 ssl http2; server_name myproject.com www.myproject.com; ssl_certificate /etc/letsencrypt/live/myproject.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/myproject.com/privkey.pem; }
Plain Text
๋ณต์‚ฌ

๋ฉ€ํ‹ฐ๋„๋ฉ”์ธ ์ธ์ฆ์„œ (ํ•œ ๊ฐœ ์ธ์ฆ์„œ๋กœ ์—ฌ๋Ÿฌ ๋„๋ฉ”์ธ)

# ํ•œ ์ธ์ฆ์„œ๋กœ ์—ฌ๋Ÿฌ ๋„๋ฉ”์ธ ์ปค๋ฒ„ certbot certonly --standalone \\ -d example.com -d www.example.com \\ -d myproject.com -d www.myproject.com \\ -d anothersite.io -d www.anothersite.io
Bash
๋ณต์‚ฌ
Nginx ์„ค์ •:
server { listen 443 ssl http2; server_name example.com www.example.com myproject.com www.myproject.com anothersite.io www.anothersite.io; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # ๊ทธ๋Ÿฐ๋ฐ ์ด ๋ฐฉ์‹์€ ๊ถŒ์žฅํ•˜์ง€ ์•Š์•„์š” (๊ฐ ๋„๋ฉ”์ธ๋ณ„๋กœ ๊ด€๋ฆฌํ•˜๊ธฐ ์–ด๋ ค์›€) }
Plain Text
๋ณต์‚ฌ

HTTP โ†’ HTTPS ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ

# HTTP โ†’ HTTPS server { listen 80; server_name example.com www.example.com myproject.com www.myproject.com anothersite.io www.anothersite.io; return 301 https://$server_name$request_uri; }
Plain Text
๋ณต์‚ฌ

๋””๋ ‰ํ† ๋ฆฌ ๊ตฌ์กฐ

/var/www/ โ”œโ”€โ”€ example/ # domain 1 โ”‚ โ”œโ”€โ”€ html/ โ”‚ โ”‚ โ”œโ”€โ”€ index.html โ”‚ โ”‚ โ”œโ”€โ”€ about.html โ”‚ โ”‚ โ””โ”€โ”€ contact.html โ”‚ โ”œโ”€โ”€ uploads/ # ์—…๋กœ๋“œ ๋””๋ ‰ํ† ๋ฆฌ โ”‚ โ””โ”€โ”€ logs/ โ”‚ โ””โ”€โ”€ access.log โ”‚ โ”œโ”€โ”€ myproject/ # domain 2 โ”‚ โ”œโ”€โ”€ html/ โ”‚ โ”‚ โ”œโ”€โ”€ index.html โ”‚ โ”‚ โ””โ”€โ”€ dashboard.html โ”‚ โ””โ”€โ”€ uploads/ โ”‚ โ””โ”€โ”€ anothersite/ # domain 3 โ”œโ”€โ”€ html/ โ”‚ โ”œโ”€โ”€ index.html โ”‚ โ””โ”€โ”€ blog/ โ””โ”€โ”€ uploads/ /etc/nginx/ โ”œโ”€โ”€ nginx.conf # ๋ฉ”์ธ ์„ค์ • โ””โ”€โ”€ conf.d/ โ”œโ”€โ”€ example.com.conf โ”œโ”€โ”€ myproject.com.conf โ””โ”€โ”€ anothersite.io.conf
Plain Text
๋ณต์‚ฌ

Nginx ์„ค์ • ํŒŒ์ผ ๋ถ„๋ฆฌ (๊ถŒ์žฅ)

๊ตฌ์กฐ
cd /etc/nginx/conf.d/
Bash
๋ณต์‚ฌ
/etc/nginx/conf.d/example.com.conf
server { listen 80; server_name example.com www.example.com; root /var/www/example; access_log /var/log/nginx/example.com_access.log; error_log /var/log/nginx/example.com_error.log; # ... }
Plain Text
๋ณต์‚ฌ
/etc/nginx/conf.d/myproject.com.conf
server { listen 80; server_name myproject.com www.myproject.com; root /var/www/myproject; access_log /var/log/nginx/myproject.com_access.log; error_log /var/log/nginx/myproject.com_error.log; # ... }
Plain Text
๋ณต์‚ฌ

/etc/nginx/conf.d vs /etc/nginx/sites-available

1. /etc/nginx/conf.d

ํŒŒ์ผ ๋„ฃ์œผ๋ฉด ๋ฐ”๋กœ ์ ์šฉ๋˜๋Š” ๊ตฌ์กฐ
/etc/nginx/conf.d/mysite.conf
Bash
๋ณต์‚ฌ

ํŠน์ง•

โ€ข
nginx.conf์—์„œ ์ด๋ ‡๊ฒŒ ํฌํ•จ๋จ
include /etc/nginx/conf.d/*.conf;
Plain Text
๋ณต์‚ฌ
.conf ํŒŒ์ผ์ด๋ฉด ์ „๋ถ€ ์ž๋™ ์ ์šฉ
์‹ฌ๋ณผ๋ฆญ ๋งํฌ ํ•„์š” ์—†์Œ

์žฅ์ 

โ€ข
๋น ๋ฅด๊ณ  ๊ฐ„๋‹จ
โ€ข
Docker / ํ…Œ์ŠคํŠธ ํ™˜๊ฒฝ์— ์ตœ์ 

๋‹จ์ 

โ€ข
ํ™œ์„ฑ/๋น„ํ™œ์„ฑ ๊ด€๋ฆฌ ๋ถˆํŽธ
โ†’ ๋„๋ ค๋ฉด ํŒŒ์ผ ์‚ญ์ œ or ์ด๋ฆ„ ๋ณ€๊ฒฝ

2. /etc/nginx/sites-available + sites-enabled

ํ™œ์„ฑํ™” ๊ฐœ๋…์ด ์žˆ๋Š” ๊ตฌ์กฐ (2๋‹จ๊ณ„)
/etc/nginx/sites-available/mysite # ์ž‘์„ฑ /etc/nginx/sites-enabled/mysite # ํ™œ์„ฑํ™” (symlink)
Bash
๋ณต์‚ฌ

ํŠน์ง•

include /etc/nginx/sites-enabled/*;
Plain Text
๋ณต์‚ฌ
sites-enabled์— ์žˆ๋Š” ๊ฒƒ๋งŒ ์ ์šฉ๋จ

์žฅ์ 

โ€ข
์‚ฌ์ดํŠธ ON/OFF ์‰ฌ์›€
ln -s # ํ™œ์„ฑํ™” rm # ๋น„ํ™œ์„ฑํ™”
Bash
๋ณต์‚ฌ
โ€ข
์šด์˜ ์„œ๋ฒ„์—์„œ ๊ด€๋ฆฌ ๋งค์šฐ ํŽธํ•จ
โ€ข
์—ฌ๋Ÿฌ ๋„๋ฉ”์ธ ๊ด€๋ฆฌ์— ์œ ๋ฆฌ

๋‹จ์ 

โ€ข
ํ•œ ๋‹จ๊ณ„ ๋” ์žˆ์Œ (์ดˆ๋ณด์ž์—๊ฒ ๋ฒˆ๊ฑฐ๋กœ์›€)

์ฐจ์ด ํ•œ๋ˆˆ์— ๋น„๊ต

๊ตฌ๋ถ„
conf.d
sites-available
์ ์šฉ ๋ฐฉ์‹
์ž๋™
์ˆ˜๋™ ํ™œ์„ฑํ™”
์‹ฌ๋ณผ๋ฆญ ๋งํฌ
์—†์Œ
ํ•„์š”
๊ด€๋ฆฌ ํŽธ์˜์„ฑ
๋‚ฎ์Œ
๋†’์Œ
์‚ฌ์šฉ ํ™˜๊ฒฝ
Docker / ๊ฐ„๋‹จ ์„œ๋ฒ„
์šด์˜ / ์‹ค๋ฌด
๋น„ํ™œ์„ฑํ™”
ํŒŒ์ผ ์‚ญ์ œ
๋งํฌ ์ œ๊ฑฐ

์‹ค๋ฌด ๊ฐ๊ฐ์œผ๋กœ ์ •๋ฆฌ

conf.d = โ€œ๊ทธ๋ƒฅ ๋„ฃ์œผ๋ฉด ๋ฐ”๋กœ ์ ์šฉ๋˜๋Š” ํด๋”โ€
sites-available = โ€œ์„ค์ • ์ €์žฅ์†Œ + ์„ ํƒ ์ ์šฉ ๊ตฌ์กฐโ€

์ถ”์ฒœ ๊ธฐ์ค€

โ€ข
๋น ๋ฅด๊ฒŒ ํ…Œ์ŠคํŠธ conf.d
โ€ข
์„œ๋น„์Šค ์šด์˜ sites-available

ํ•œ ์ค„ ์ •๋ฆฌ

conf.d๋Š” ์ž๋™ ์‹คํ–‰, sites-available์€ ์Šน์ธ ํ›„ ์‹คํ–‰ ๊ตฌ์กฐ

์‹ค์ „ ์˜ˆ์ œ: ๋„๋ฉ”์ธ๋ณ„ ๋‹ค๋ฅธ ์„ค์ •

flowchart TD
    A["ํด๋ผ์ด์–ธํŠธ ์š”์ฒญ"]
    B{"Host ํ—ค๋” ํ™•์ธ"}

    A -->|"์š”์ฒญ"| B

    B -->|"example.com"| C["์ •์  ํŒŒ์ผ ์„œ๋น™<br/>(์ •์  ์‚ฌ์ดํŠธ)"]
    B -->|"myproject.com"| D["๋ฆฌ๋ฒ„์Šค ํ”„๋ก์‹œ<br/>(API ๋ฐฑ์—”๋“œ)"]
    B -->|"anothersite.io"| E["WordPress<br/>(PHP)"]

    C --> F["์‘๋‹ต"]
    D --> F
    E --> F
Mermaid
๋ณต์‚ฌ
# ============================================ # 1. example.com - ์ •์  ์‚ฌ์ดํŠธ # ============================================ server { listen 443 ssl http2; server_name example.com www.example.com; root /var/www/example; index index.html; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # ์ •์  ํŒŒ์ผ ์บ์‹ฑ location ~* \\.(js|css|jpg|png|gif|ico|woff|woff2)$ { expires 1y; add_header Cache-Control "public, immutable"; } location / { try_files $uri $uri/ =404; } } # ============================================ # 2. myproject.com - API ๋ฐฑ์—”๋“œ (Spring Boot) # ============================================ server { listen 443 ssl http2; server_name myproject.com www.myproject.com; ssl_certificate /etc/letsencrypt/live/myproject.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/myproject.com/privkey.pem; # REST API ๋ฆฌ๋ฒ„์Šค ํ”„๋ก์‹œ location / { proxy_pass <http://localhost:8080>; proxy_set_header Host $host; 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; } } # ============================================ # 3. anothersite.io - PHP (WordPress) # ============================================ server { listen 443 ssl http2; server_name anothersite.io www.anothersite.io; root /var/www/anothersite; index index.php; ssl_certificate /etc/letsencrypt/live/anothersite.io/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/anothersite.io/privkey.pem; # PHP-FPM ์—ฐ๊ฒฐ location ~ \\.php$ { fastcgi_pass unix:/var/run/php/php-fpm.sock; fastcgi_index index.php; include fastcgi_params; } # WordPress ํผ๋จธ๋งํฌ location / { try_files $uri $uri/ /index.php?$args; } } # ============================================ # HTTP โ†’ HTTPS ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ # ============================================ server { listen 80; server_name example.com www.example.com myproject.com www.myproject.com anothersite.io www.anothersite.io; return 301 https://$server_name$request_uri; }
Plain Text
๋ณต์‚ฌ

์„ฑ๋Šฅ ์ตœ์ ํ™”

๋„๋ฉ”์ธ๋ณ„ ๋กœ๊ทธ ๋ถ„๋ฆฌ

server { listen 80; server_name example.com; # domain 1์˜ ๋กœ๊ทธ๋งŒ ๊ธฐ๋ก access_log /var/log/nginx/example.com_access.log; error_log /var/log/nginx/example.com_error.log warn; # ... } server { listen 80; server_name myproject.com; # domain 2์˜ ๋กœ๊ทธ๋งŒ ๊ธฐ๋ก access_log /var/log/nginx/myproject.com_access.log; error_log /var/log/nginx/myproject.com_error.log warn; # ... }
Plain Text
๋ณต์‚ฌ

์••์ถ• ์„ค์ • (๋„๋ฉ”์ธ๋ณ„)

server { listen 80; server_name example.com; # ํ…์ŠคํŠธ ์••์ถ• gzip on; gzip_types text/html text/plain text/css application/json application/javascript; gzip_min_length 1000; # ... }
Plain Text
๋ณต์‚ฌ

๋„๋ฉ”์ธ๋ณ„ SSL ์ธ์ฆ์„œ ๊ด€๋ฆฌ

๋„๋ฉ”์ธ
์ธ์ฆ์„œ ๊ฒฝ๋กœ
๊ฐฑ์‹  ์ƒํƒœ
example.com
/etc/letsencrypt/live/example.com/
Auto renewal
myproject.com
/etc/letsencrypt/live/myproject.com/
Auto renewal
anothersite.io
/etc/letsencrypt/live/anothersite.io/
Auto renewal
# ๋ชจ๋“  ์ธ์ฆ์„œ ์ž๋™ ๊ฐฑ์‹  ํ™•์ธ certbot renew --dry-run # ์ธ์ฆ์„œ ๋ชฉ๋ก certbot certificates # ํŠน์ • ๋„๋ฉ”์ธ ๊ฐฑ์‹  certbot renew --cert-name example.com
Bash
๋ณต์‚ฌ

์ฃผ์˜์‚ฌํ•ญ ๋ฐ ๋ฌธ์ œ ํ•ด๊ฒฐ

1. ์ด์ƒํ•œ ๋„๋ฉ”์ธ์œผ๋กœ ์ ‘์†ํ•˜๋ฉด?

# ๋“ฑ๋ก๋˜์ง€ ์•Š์€ ๋„๋ฉ”์ธ: curl -H "Host: unknown.com" <http://localhost> # โ†’ Nginx๋Š” ์–ด๋–ค server_name๊ณผ๋„ ๋งค์นญ ์•ˆ ๋˜๋ฉด?
Bash
๋ณต์‚ฌ
ํ•ด๊ฒฐ์ฑ…: ๊ธฐ๋ณธ ์„œ๋ฒ„ ๋ธ”๋ก ์„ค์ •
# ๊ฐ€์žฅ ๋จผ์ € ์ •์˜๋œ ์„œ๋ฒ„ ๋ธ”๋ก์ด ๊ธฐ๋ณธ๊ฐ’ ์—ญํ•  server { listen 80 default_server; # ๐Ÿ‘ˆ default_server ์ถ”๊ฐ€ server_name _; return 444; # ์—ฐ๊ฒฐ ๋Š๊ธฐ }
Plain Text
๋ณต์‚ฌ

2. SSL ์ธ์ฆ์„œ ๊ฐฑ์‹  ์‹คํŒจ

# ๋ฌธ์ œ: certbot์ด ์ธ์ฆ์„œ๋ฅผ ๊ฐฑ์‹ ํ•˜์ง€ ๋ชปํ•จ # ์›์ธ: ํฌํŠธ 80์ด๋‚˜ 443์ด ๋‹ซํ˜€์žˆ์Œ # ํ•ด๊ฒฐ์ฑ… certbot renew --force-renewal # ๋˜๋Š” ์ด๋ฏธ ์‹คํ–‰ ์ค‘์ธ Nginx ์ž ๊น ์ค‘์ง€ sudo systemctl stop nginx sudo certbot renew sudo systemctl start nginx
Bash
๋ณต์‚ฌ

3. ํŠน์ • ๋„๋ฉ”์ธ๋งŒ ๋А๋ฆผ

# ๊ฐ ๋„๋ฉ”์ธ๋ณ„ ์‘๋‹ต ์‹œ๊ฐ„ ํ™•์ธ curl -w "@curl-format.txt" -o /dev/null -s <https://example.com> curl -w "@curl-format.txt" -o /dev/null -s <https://myproject.com> # ๋„๋ฉ”์ธ๋ณ„ ์—๋Ÿฌ ๋กœ๊ทธ ํ™•์ธ tail -f /var/log/nginx/example.com_error.log
Bash
๋ณต์‚ฌ

์ฒดํฌ๋ฆฌ์ŠคํŠธ

๊ฐ ๋„๋ฉ”์ธ DNS A ๋ ˆ์ฝ”๋“œ ์„ค์ • ์™„๋ฃŒ? (๋ชจ๋‘ ๊ฐ™์€ IP)
Nginx ์„ค์ • ํŒŒ์ผ์—์„œ server_name ์ •ํ™•ํžˆ ์ž…๋ ฅ?
๊ฐ ๋„๋ฉ”์ธ์šฉ root ๋””๋ ‰ํ† ๋ฆฌ ์ƒ์„ฑ? (/var/www/example, /var/www/myproject)
nginx -t๋กœ ์„ค์ • ํ…Œ์ŠคํŠธ?
systemctl reload nginx ์‹คํ–‰?
๊ฐ ๋„๋ฉ”์ธ์œผ๋กœ ์ ‘์† ํ…Œ์ŠคํŠธ? (curl -H "Host: example.com" <http://localhost>)
SSL ์ธ์ฆ์„œ ๋ฐœ๊ธ‰ ์™„๋ฃŒ? (๋„๋ฉ”์ธ๋ณ„)
HTTP โ†’ HTTPS ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ ์„ค์ •?
๋„๋ฉ”์ธ๋ณ„ ๋กœ๊ทธ ๋ถ„๋ฆฌ ์„ค์ •?
certbot renew ์ž๋™ ์‹คํ–‰ ๋“ฑ๋ก?
www ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ ์„ค์ •?
๋ฐฉํ™”๋ฒฝ ํฌํŠธ 80, 443 ๊ฐœ๋ฐฉ?

ํ•ต์‹ฌ ์ •๋ฆฌ

๋ฉ€ํ‹ฐ๋„๋ฉ”์ธ = ์™„์ „ํžˆ ๋‹ค๋ฅธ ์—ฌ๋Ÿฌ ๋„๋ฉ”์ธ์„ 1๊ฐœ Nginx ์„œ๋ฒ„์—์„œ ๊ด€๋ฆฌ
DNS ์„ค์ • = ๊ฐ ๋„๋ฉ”์ธ์ด ๊ฐ™์€ Nginx ์„œ๋ฒ„ IP๋กœ ํ–ฅํ•˜๊ฒŒ
server_name = HTTP Host ํ—ค๋”๋กœ ์–ด๋А ๋„๋ฉ”์ธ์ธ์ง€ ํŒ๋‹จ, ๊ฐ ๋ธ”๋ก์—์„œ ๋‹ค๋ฅด๊ฒŒ ์ฒ˜๋ฆฌ
SSL ์ธ์ฆ์„œ = ๊ฐ ๋„๋ฉ”์ธ๋ณ„ ๊ฐœ๋ณ„ ์ธ์ฆ์„œ ๋˜๋Š” ๋ฉ€ํ‹ฐ๋„๋ฉ”์ธ ์ธ์ฆ์„œ
๋กœ๊ทธ ๋ถ„๋ฆฌ = ๊ฐ ๋„๋ฉ”์ธ๋ณ„ access_log, error_log ๋”ฐ๋กœ ๊ด€๋ฆฌ
์žฅ์  = ์„œ๋ฒ„ ๋น„์šฉ ์ ˆ๊ฐ, ํ†ตํ•ฉ ๊ด€๋ฆฌ, ๊ฐ„๋‹จํ•œ ๋ฆฌ์†Œ์Šค ๊ณต์œ 
๋‹จ์  = ๋ณต์žก๋„ ์ฆ๊ฐ€, ๋„๋ฉ”์ธ ์ˆ˜๋งŒํผ ์„ค์ •๋Ÿ‰ ์ฆ๊ฐ€