-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnginx.conf
94 lines (77 loc) · 2.71 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
87
88
89
90
91
92
93
94
user www-data;
worker_processes auto;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log debug;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
gzip off;
server {
listen 8443 ssl;
server_name 192.168.0.51;
ssl_certificate /etc/nginx/ssl/selfsigned.crt;
ssl_certificate_key /etc/nginx/ssl/selfsigned.key;
# Serve static files from the frontend build directory
root /app/data/public/dist;
index index.html;
# Add security headers
add_header X-Content-Type-Options "nosniff" always;
add_header Cache-Control "public, max-age=3600" always;
# Simplify the Server header
server_tokens off;
add_header Server nginx;
# Handle WebSocket connections at /ws
location /ws {
proxy_pass http://127.0.0.1:8080/ws;
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;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
# Proxy API requests to the backend
location /api/ {
proxy_pass http://127.0.0.1:8080/api/;
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;
}
# Serve JavaScript files with correct MIME type and charset
location ~* \.js$ {
types { application/javascript js; }
charset utf-8;
add_header Cache-Control "public, max-age=3600";
}
# Serve HTML files with correct MIME type and charset
location ~* \.html$ {
types { text/html html; }
charset utf-8;
add_header Cache-Control "public, max-age=3600";
}
# Serve favicon.ico with correct MIME type
location = /favicon.ico {
types { image/x-icon ico; }
add_header Cache-Control "public, max-age=86400";
}
# Fallback for Single Page Application (SPA) routing
location / {
try_files $uri $uri/ /index.html;
}
}
}