# Windows Nginx 主配置文件 worker_processes auto; error_log logs/error.log notice; pid logs/nginx.pid; events { worker_connections 2048; } http { include mime.types; default_type application/octet-stream; # 日志格式定义 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; log_format api_log '$remote_addr - $remote_user [$time_local] ' '"$request_method $request_uri HTTP/$server_protocol" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" ' 'request_time="$request_time" ' 'upstream_response_time="$upstream_response_time" ' 'request_length="$request_length"'; log_format json_log '$remote_addr - $remote_user [$time_local] ' '"$request_method $request_uri HTTP/$server_protocol" ' '$status $body_bytes_sent ' '"$http_referer" "$http_user_agent" ' '"$http_x_forwarded_for" ' 'request_body="$request_body" ' 'content_type="$content_type" ' 'request_time="$request_time" ' 'upstream_response_time="$upstream_response_time"'; # 全局日志(server 中可覆盖) access_log logs/access.log main; error_log logs/error.log error; # 全局配置 client_max_body_size 300M; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; # Gzip 压缩 gzip on; gzip_vary on; gzip_min_length 1000; gzip_proxied any; gzip_comp_level 6; gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml+rss application/rss+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml; # 后端服务器配置 upstream api_backend { server 127.0.0.1:8081; } upstream server_backend { server 127.0.0.1:8085; } # 引入 server 配置 include conf.d/*.conf; }