Files
performance-evaluation-system/nginx.conf
2026-04-14 09:39:40 +08:00

94 lines
3.1 KiB
Nginx Configuration File

# Nginx configuration for performance appraisal system
# This file will be mounted into nginx container
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
# Logging
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;
error_log /var/log/nginx/error.log warn;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
# Real IP configuration for proxy (ESA HTTPS proxy)
real_ip_header X-Forwarded-For;
set_real_ip_from 0.0.0.0/0; # Trust all proxies (adjust if you know ESA proxy IPs)
# Server block for domain
server {
listen 80;
server_name performance-appraisal.excn.top;
# Redirect to HTTPS if request came via HTTP (not from ESA proxy)
if ($http_x_forwarded_proto = "http") {
return 301 https://$server_name$request_uri;
}
# Frontend React development server (via Docker network)
location / {
proxy_pass http://frontend:3000;
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 $http_x_forwarded_proto;
# WebSocket support for hot reload (development)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# Backend API reverse proxy
location /api/ {
proxy_pass http://backend:3001/;
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 $http_x_forwarded_proto;
# Increase timeout for long-running AI requests
proxy_read_timeout 120s;
proxy_connect_timeout 15s;
proxy_send_timeout 15s;
}
# Static assets (if any)
location /assets/ {
proxy_pass http://frontend:3000/assets/;
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 $http_x_forwarded_proto;
# Cache static assets
expires 30d;
add_header Cache-Control "public, immutable";
}
# Health check endpoint
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
}
# Optional: Redirect www to non-www
server {
listen 80;
server_name www.performance-appraisal.excn.top;
return 301 https://performance-appraisal.excn.top$request_uri;
}
}