demo/nginx/conf/nginx.conf

56 lines
1.6 KiB
Nginx Configuration File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

worker_processes auto;
events {
# worker_connections 1024;
worker_connections 20480;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
# 建议改用绝对路径,防止容器找不到 logs 目录
access_log /etc/nginx/logs/access.log main;
# 💡 关键WebSocket 支持
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 1024m;
proxy_connect_timeout 60;
proxy_read_timeout 300;
proxy_send_timeout 300;
fastcgi_buffers 8 128k;
send_timeout 300;
client_header_timeout 300;
client_body_timeout 300;
reset_timedout_connection on;
# --- Gzip 配置开始 ---
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml image/png application/zip application/x-shockwave-flash application/javascript application/json;
gzip_disable "MSIE [1-6]\.";
gzip_vary on;
# --- Gzip 配置结束 ---
# 引入子配置文件
include /etc/nginx/conf/conf.d/*.conf;
}