Repository navigation
Expand file tree
/
Copy pathnginx.conf
More file actions
55 lines (46 loc) ยท 2.33 KB
/
Copy pathnginx.conf
File metadata and controls
55 lines (46 loc) ยท 2.33 KB
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
events {
worker_connections 1024; # worker ํ๋ก์ธ์๊ฐ ๋์์ ์ฒ๋ฆฌํ ์ ์๋ ์ต๋ ์ฐ๊ฒฐ ์ ์ค์
}
http {
# Spring Boot ์ปจํ
์ด๋์ ํต์ ์ค์
# ๋์ปค ๋ด์ฅ DNS ์๋ฒ ์ค์ - 30์ด๋ง๋ค 'app'์ IP๊ฐ ๋ฐ๋์๋์ง ๋ค์ ํ์ธ
resolver 127.0.0.11 valid=30s;
# HTTP ์ฒ๋ฆฌ
server {
listen 80; # Nginx ์ปจํ
์ด๋์ ๋ด๋ถ ํฌํธ
server_name www.hrr-official.cloud hrr-official.cloud;
# Certbot ์ธ์ฆ์ ์ํ ๊ฒฝ๋ก ์ค์
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
# ๋๋จธ์ง ๋ชจ๋ HTTP ์์ฒญ์ HTTPS๋ก 301 ์๊ตฌ ๋ฆฌ๋ค์ด๋ ํธ
location / {
return 301 https://$host$request_uri;
}
}
# HTTPS ์ฒ๋ฆฌ ์๋ฒ
server {
listen 443 ssl;
server_name www.hrr-official.cloud hrr-official.cloud;
# Certbot์ผ๋ก ๋ฐ๊ธ๋ฐ์ ์ธ์ฆ์ ๊ฒฝ๋ก ์ง์
ssl_certificate /etc/letsencrypt/live/hrr-official.cloud/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/hrr-official.cloud/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
ssl_prefer_server_ciphers on;
# ๋ชจ๋ ์์ฒญ์ Spring Boot ์ฑ์ผ๋ก ์ ๋ฌํ๋ ์ค์
location / {
# ๋ณ์๋ฅผ ์ฌ์ฉํ์ฌ proxy_pass ์ค์
# ์ฃผ์๋ฅผ ๋ณ์์ ๋ด์์ ์ฌ์ฉํด์ผ Nginx๊ฐ ์์์ ์ค์ ํ resolver๋ฅผ ํตํด IP๋ฅผ ์ฌ์กฐํ
# service-env.inc๋ ๋ฐ๋์ 'set $service_url http://์๋น์ค๋ช
:ํฌํธ;' ํ์์ ์ง์ผ์ผ ํจ
# ํ๋กํ ์ฝ(http://)์ด ๋๋ฝ๋๋ฉด Nginx๊ฐ ์ ์์ ์ผ๋ก ํ๋ก์๋ฅผ ์ํํ ์ ์์
include /etc/nginx/conf.d/service-env.inc; # ์ปจํ
์ด๋ ๋ด๋ถ ๊ฒฝ๋ก์์ ์ค์ ํ์ผ ๋ถ๋ฌ์ค๊ธฐ
proxy_pass $service_url;
# ํด๋ผ์ด์ธํธ์ ์ค์ IP์ HTTPS ์ ๋ณด๋ฅผ Spring Boot ์ฑ์ ์ ๋ฌ
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 https; # HTTPS ์ฌ์ฉ ๋ช
์
}
}
}