This commit is contained in:
beabigegg
2025-09-23 08:27:58 +08:00
parent ed9250db1a
commit 0a89c19fc9
11 changed files with 230 additions and 38 deletions

10
nginx/Dockerfile Normal file
View File

@@ -0,0 +1,10 @@
FROM nginx:1.25-alpine
# Copy custom nginx configuration
COPY nginx.conf /etc/nginx/nginx.conf
# Expose port
EXPOSE 12010
# Start nginx
CMD ["nginx", "-g", "daemon off;"]

67
nginx/nginx.conf Normal file
View File

@@ -0,0 +1,67 @@
user nginx;
worker_processes auto;
events {
worker_connections 1024;
multi_accept on;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
gzip on;
gzip_comp_level 5;
gzip_min_length 1024;
gzip_proxied any;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
upstream app_backend {
server translator-app:12010 max_fails=3 fail_timeout=10s;
keepalive 64;
}
server {
listen 12010;
server_name _;
# Adjust for document uploads (can be large)
client_max_body_size 500m;
# Proxy API requests to Flask/Gunicorn
location /api/ {
proxy_pass http://app_backend;
proxy_http_version 1.1;
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 600s; # Longer timeout for translation processing
proxy_send_timeout 600s;
proxy_connect_timeout 10s;
proxy_buffering off; # Disable buffering for real-time progress
}
# All other routes (frontend SPA and static) via backend
location / {
proxy_pass http://app_backend;
proxy_http_version 1.1;
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 120s;
proxy_send_timeout 120s;
proxy_connect_timeout 5s;
proxy_buffering on;
proxy_buffers 32 32k;
proxy_busy_buffers_size 64k;
}
}
}