Nginx 核心配置指令

核心指令主要控制进程、连接、日志、文件和超时。以下为通用基线,业务指令放在 conf.d 中单独维护。

推荐基线

user www;
worker_processes auto;
worker_rlimit_nofile 65535;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log warn;

events {
    worker_connections 10240;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    sendfile on;
    tcp_nopush on;
    keepalive_timeout 65;
    server_tokens off;
    client_max_body_size 20m;
    include /etc/nginx/conf.d/*.conf;
}

常用检查

nginx -t
nginx -T
nginx -s reload