DataSage12 commited on
Commit
5920d8e
·
1 Parent(s): ff10b17

Add docker/nginx.conf - Fix Docker build issue

Browse files
Files changed (1) hide show
  1. docker/nginx.conf +181 -0
docker/nginx.conf ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ===========================================
2
+ # Configuration Nginx pour HOLOKIA-AVATAR
3
+ # Reverse proxy et serveur statique
4
+ # ===========================================
5
+
6
+ # user nginx;
7
+ worker_processes auto;
8
+ error_log /var/log/nginx/error.log notice;
9
+ pid /app/nginx.pid;
10
+
11
+ events {
12
+ worker_connections 1024;
13
+ use epoll;
14
+ multi_accept on;
15
+ }
16
+
17
+ http {
18
+ include /etc/nginx/mime.types;
19
+ default_type application/octet-stream;
20
+
21
+ # Logging
22
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
23
+ '$status $body_bytes_sent "$http_referer" '
24
+ '"$http_user_agent" "$http_x_forwarded_for"';
25
+ access_log /var/log/nginx/access.log main;
26
+
27
+ # Performance
28
+ sendfile on;
29
+ tcp_nopush on;
30
+ tcp_nodelay on;
31
+ keepalive_timeout 65;
32
+ types_hash_max_size 2048;
33
+ client_max_body_size 50M;
34
+
35
+ # Gzip compression
36
+ gzip on;
37
+ gzip_vary on;
38
+ gzip_min_length 1024;
39
+ gzip_proxied any;
40
+ gzip_comp_level 6;
41
+ gzip_types
42
+ text/plain
43
+ text/css
44
+ text/xml
45
+ text/javascript
46
+ application/json
47
+ application/javascript
48
+ application/xml+rss
49
+ application/atom+xml
50
+ image/svg+xml;
51
+
52
+ # Rate limiting
53
+ limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
54
+ limit_req_zone $binary_remote_addr zone=static:10m rate=30r/s;
55
+
56
+ # Upstream backend services (localhost for unified container)
57
+ upstream backend_tts {
58
+ server localhost:5000;
59
+ }
60
+
61
+ upstream backend_stt {
62
+ server localhost:5001;
63
+ }
64
+
65
+ upstream backend_llm {
66
+ server localhost:5002;
67
+ }
68
+
69
+ upstream backend_live {
70
+ server localhost:5003;
71
+ }
72
+
73
+ server {
74
+ listen 7860;
75
+ server_name _;
76
+ root /usr/share/nginx/html;
77
+ index index.html;
78
+
79
+ # Security headers
80
+ add_header X-Frame-Options "SAMEORIGIN" always;
81
+ add_header X-Content-Type-Options "nosniff" always;
82
+ add_header X-XSS-Protection "1; mode=block" always;
83
+ add_header Referrer-Policy "strict-origin-when-cross-origin" always;
84
+
85
+ # API routes
86
+ location /api/tts/ {
87
+ limit_req zone=api burst=20 nodelay;
88
+ proxy_pass http://backend_tts/;
89
+ proxy_set_header Host $host;
90
+ proxy_set_header X-Real-IP $remote_addr;
91
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
92
+ proxy_set_header X-Forwarded-Proto $scheme;
93
+ proxy_connect_timeout 30s;
94
+ proxy_send_timeout 30s;
95
+ proxy_read_timeout 30s;
96
+ }
97
+
98
+ location /api/stt/ {
99
+ limit_req zone=api burst=20 nodelay;
100
+ proxy_pass http://backend_stt/;
101
+ proxy_set_header Host $host;
102
+ proxy_set_header X-Real-IP $remote_addr;
103
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
104
+ proxy_set_header X-Forwarded-Proto $scheme;
105
+ proxy_connect_timeout 30s;
106
+ proxy_send_timeout 30s;
107
+ proxy_read_timeout 30s;
108
+ }
109
+
110
+ location /api/llm/ {
111
+ limit_req zone=api burst=10 nodelay;
112
+ proxy_pass http://backend_llm/;
113
+ proxy_set_header Host $host;
114
+ proxy_set_header X-Real-IP $remote_addr;
115
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
116
+ proxy_set_header X-Forwarded-Proto $scheme;
117
+ proxy_connect_timeout 60s;
118
+ proxy_send_timeout 60s;
119
+ proxy_read_timeout 60s;
120
+ }
121
+
122
+ # Audio files from TTS service
123
+ location /audio/ {
124
+ proxy_pass http://backend_tts/audio/;
125
+ proxy_set_header Host $host;
126
+ proxy_set_header X-Real-IP $remote_addr;
127
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
128
+ proxy_set_header X-Forwarded-Proto $scheme;
129
+ proxy_connect_timeout 30s;
130
+ proxy_send_timeout 30s;
131
+ proxy_read_timeout 30s;
132
+ }
133
+
134
+ # WebSocket for live streaming
135
+ location /ws/ {
136
+ proxy_pass http://backend_live/;
137
+ proxy_http_version 1.1;
138
+ proxy_set_header Upgrade $http_upgrade;
139
+ proxy_set_header Connection "upgrade";
140
+ proxy_set_header Host $host;
141
+ proxy_set_header X-Real-IP $remote_addr;
142
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
143
+ proxy_set_header X-Forwarded-Proto $scheme;
144
+ proxy_connect_timeout 7d;
145
+ proxy_send_timeout 7d;
146
+ proxy_read_timeout 7d;
147
+ }
148
+
149
+ # Static assets with caching
150
+ location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
151
+ limit_req zone=static burst=50 nodelay;
152
+ expires 1y;
153
+ add_header Cache-Control "public, immutable";
154
+ try_files $uri =404;
155
+ }
156
+
157
+ # GLB models with longer caching
158
+ location ~* \.glb$ {
159
+ limit_req zone=static burst=20 nodelay;
160
+ expires 1y;
161
+ add_header Cache-Control "public, immutable";
162
+ add_header Content-Type "model/gltf-binary";
163
+ try_files $uri =404;
164
+ }
165
+
166
+ # Main application
167
+ location / {
168
+ try_files $uri $uri/ /index.html;
169
+ add_header Cache-Control "no-cache, no-store, must-revalidate";
170
+ add_header Pragma "no-cache";
171
+ add_header Expires "0";
172
+ }
173
+
174
+ # Health check
175
+ location /health {
176
+ access_log off;
177
+ return 200 "healthy\n";
178
+ add_header Content-Type text/plain;
179
+ }
180
+ }
181
+ }