nginx-proxy-ai/nginx.conf

75 lines
2.1 KiB
Nginx Configuration File
Raw 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.

events {
worker_connections 1024;
}
http {
# --- 基础 IO 优化 ---
sendfile on;
tcp_nopush on;
tcp_nodelay on;
# --- Keepalive ---
keepalive_timeout 65;
keepalive_requests 1000;
# --- 客户端超时(防慢连接拖死 worker---
client_max_body_size 16m;
client_body_buffer_size 128k;
client_header_buffer_size 1k;
large_client_header_buffers 4 8k;
client_body_timeout 30s;
client_header_timeout 30s;
send_timeout 30s;
# --- 反代默认参数(各 conf.d 可按需覆盖)---
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_set_header Connection "";
proxy_connect_timeout 3s;
proxy_send_timeout 30s;
proxy_read_timeout 30s;
proxy_buffer_size 16k;
proxy_buffers 8 16k;
proxy_busy_buffers_size 32k;
# --- Gzip 压缩 ---
gzip on;
gzip_min_length 1k;
gzip_comp_level 5;
gzip_types text/plain text/css application/json application/javascript application/xml image/svg+xml;
gzip_proxied any;
gzip_vary on;
# --- SSL 安全配置 ---
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1d;
ssl_session_tickets on;
# --- 关闭版本号 ---
server_tokens off;
include /etc/nginx/conf.d/*.conf;
# 所有 HTTP 自动跳 HTTPS
server {
listen 80 default_server;
server_name _;
location / {
return 301 https://$host$request_uri;
}
# 让证书续期正常工作(必须留)
location /.well-known/acme-challenge/ {
root /var/www/html;
try_files $uri =404;
}
}
}