-
Notifications
You must be signed in to change notification settings - Fork 4
/
nginx.conf
87 lines (70 loc) · 2.68 KB
/
nginx.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
75
76
77
78
79
80
81
82
83
84
85
86
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
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;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_tokens off;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "DENY" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
include /etc/nginx/conf.d/*.conf;
# Upstream 정의
upstream app {
server app1:8080;
server app2:8080;
server app3:8080;
}
server {
listen 80;
listen [::]:80;
server_name chzz.store;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name chzz.store;
server_tokens off;
ssl_certificate /etc/letsencrypt/live/chzz.store/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/chzz.store/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
client_max_body_size 50M; # 최대 파일 업로드 크기 50MB로 설정
location / {
proxy_pass http://app;
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;
}
location /api/v1/notifications/subscribe {
proxy_pass http://app;
proxy_http_version 1.1;
proxy_set_header Connection '';
proxy_set_header Cache_Control 'no-cache';
chunked_transfer_encoding on;
proxy_read_timeout 90s; # Nginx가 백엔드 서버로부터 데이터를 받지 못하는 동안 대기할 최대 시간, 이 시간 동안 데이터가 안오면 연결 끊음 (클라이언트에서 재연결 요청) 서버의 heartbeat 시간보다 조금 길게
}
}
}