/
/
/
1user nginx;
2worker_processes auto;
3error_log /var/log/nginx/error.log notice;
4pid /var/run/nginx.pid;
5
6events {
7 worker_connections 1024;
8}
9
10http {
11 include /etc/nginx/mime.types;
12 default_type application/octet-stream;
13
14 log_format main '$remote_addr - $remote_user [$time_local] "$request" '
15 '$status $body_bytes_sent "$http_referer" '
16 '"$http_user_agent"';
17
18 access_log /var/log/nginx/access.log main;
19
20 sendfile on;
21 tcp_nopush on;
22 keepalive_timeout 65;
23
24 gzip on;
25 gzip_vary on;
26 gzip_types text/plain text/css text/javascript application/javascript application/json;
27
28 server {
29 listen 80;
30 server_name localhost;
31 root /usr/share/nginx/html;
32 index index.html;
33
34 # API proxy to backend
35 location /api/ {
36 proxy_pass http://bag-recorder-backend:8080/api/;
37 proxy_http_version 1.1;
38 proxy_set_header Host $host;
39 proxy_set_header X-Real-IP $remote_addr;
40 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
41 proxy_set_header X-Forwarded-Proto $scheme;
42 }
43
44 # WebSocket proxy
45 location /ws {
46 proxy_pass http://bag-recorder-backend:8080/ws;
47 proxy_http_version 1.1;
48 proxy_set_header Upgrade $http_upgrade;
49 proxy_set_header Connection "Upgrade";
50 proxy_set_header Host $host;
51 proxy_set_header X-Real-IP $remote_addr;
52 proxy_read_timeout 86400;
53 }
54
55 # Static files with caching
56 location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
57 expires 1y;
58 add_header Cache-Control "public, immutable";
59 }
60
61 # SPA routing - redirect all to index.html
62 location / {
63 try_files $uri $uri/ /index.html;
64 }
65 }
66}