首页 > 技术文章 > nginx配置文件详解

xxoome 2016-12-27 15:40 原文

# Nginx用户及组:用户 组。window下不指定

user  www www;

 

# 工作进程:数目。根据硬件调整,通常等于CPU数量或者2倍于CPU。

worker_processes auto;

 

error_log  /home/wwwlogs/nginx_error.log  crit;

 

pid        /usr/local/nginx/logs/nginx.pid;

 

# Specifies the value for maximum file descriptors that can be opened by this process.

worker_rlimit_nofile 51200;

 

events

    {

     # 使用epoll的I/O 模型。

        use epoll;

        worker_connections 51200;

        multi_accept on;

    }

 

#设定http服务器,利用它的反向代理功能提供负载均衡支持

http

    {

        include       mime.types;

        default_type  application/octet-stream;

 

        server_names_hash_bucket_size 128;

 

     #客户端请求头部的缓冲区大小。这个可以根据你的系统分页大小来设置,一般一个请求头的大小不会超过1k,

     #不过由于一般系统分页都要大于1k,所以这里设置为分页大小。

     #分页大小可以用命令getconf PAGESIZE 取得。

     #[root@localhost conf]# getconf PAGESIZE

     #4096

     #但也有client_header_buffer_size超过4k的情况,

     #但是client_header_buffer_size该值必须设置为“系统分页大小”的整倍数(但是这里并没有)。

        client_header_buffer_size 32k;

 

     #客户请求头缓冲大小。nginx默认会用client_header_buffer_size这个buffer来读取header值,如果

     #header过大,它会使用large_client_header_buffers来读取

        large_client_header_buffers 4 32k;

 

     # 设定通过nginx上传文件的大小

        client_max_body_size 50m;

 

        sendfile   on;

        tcp_nopush on;

 

        keepalive_timeout 60;

 

        tcp_nodelay on;

 

        fastcgi_connect_timeout 300;

        fastcgi_send_timeout 300;

        fastcgi_read_timeout 300;

        fastcgi_buffer_size 64k;

        fastcgi_buffers 4 64k;

        fastcgi_busy_buffers_size 128k;

        fastcgi_temp_file_write_size 256k;

 

        gzip on;

        gzip_min_length  1k;

        gzip_buffers     4 16k;

        gzip_http_version 1.1;

        gzip_comp_level 2;

        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;

        gzip_vary on;

        gzip_proxied   expired no-cache no-store private auth;

        gzip_disable   "MSIE [1-6]\.";

 

        #limit_conn_zone $binary_remote_addr zone=perip:10m;

        ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.

 

        server_tokens off;

        access_log off;

 

        include vhost/*.conf;

}

 

推荐阅读