以下是一个 CentOS 7.6 的初始 nginx.conf 文件示例:

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
    worker_connections 1024;
}

http {
    include /etc/nginx/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"';

    access_log /var/log/nginx/access.log main;

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;

    keepalive_timeout 65;

    include /etc/nginx/conf.d/*.conf;
}

该配置文件指定了 Nginx 的用户和工作进程数量。它还定义了错误日志的位置和 pid 文件的位置。事件部分定义了可用连接数。HTTP 部分定义了默认 MIME 类型、日志格式、访问日志位置、文件传输方式、TCP 传输优化和 HTTP keep-alive 超时。最后,它包含任何其他配置文件在 /etc/nginx/conf.d/ 目录中。

CentOS 7.6 Nginx 初始配置文件示例

原文地址: https://www.cveoy.top/t/topic/mudB 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录