-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdefault.conf
74 lines (62 loc) Β· 1.99 KB
/
default.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# λ°±μλ μλ² μ μ
upstream backend {
server backend:3000; # λ°±μλ μλ² (NestJS)
}
# HTTP μλ² λΈλ‘
server {
listen 80;
server_name nocta.site www.nocta.site;
# Let's Encrypt μΈμ¦μ μν μ€μ
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
# HTTPSλ‘ λ¦¬λ€μ΄λ νΈ
location / {
return 301 https://$host$request_uri;
}
}
# HTTPS μλ² λΈλ‘
server {
listen 443 ssl;
server_name nocta.site www.nocta.site;
# SSL μΈμ¦μμ ν€ νμΌ κ²½λ‘
ssl_certificate /etc/letsencrypt/live/nocta.site/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/nocta.site/privkey.pem;
# SSL μ€μ
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers HIGH:!aNULL:!MD5;
# HSTS μ€μ (HTTPS κ°μ )
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
location = /robots.txt {
root /usr/share/nginx/html; # React λΉλ κ²°κ³Όλ¬Όμ΄ μλ λλ ν 리
access_log off;
add_header Cache-Control "public, max-age=86400"; # 24μκ° μΊμ±
}
location = /sitemap.xml {
root /usr/share/nginx/html;
access_log off;
add_header Cache-Control "public, max-age=86400";
}
# /api κ²½λ‘λ‘ λ€μ΄μ€λ μμ²μ λ°±μλλ‘ μ λ¬
location /api {
proxy_pass http://backend; # λ°±μλλ‘ μμ² μ λ¬
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# μ μ νμΌμ μ 곡νλ κΈ°λ³Έ κ²½λ‘ μ€μ
location / {
root /usr/share/nginx/html; # React λΉλ κ²°κ³Όλ¬Όμ΄ μμΉν λλ ν°λ¦¬
index index.html; # κΈ°λ³Έ μ§μ
μ νμΌ
try_files $uri /index.html; # SPA λΌμ°ν
μ§μ
}
# 404 μλ¬ νμ΄μ§ μ€μ
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
}