• nginx调优配置


    • nginx调优配置

    user www www;

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

    worker_processes 8;

    worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;

    #错误日志文件及其级别;出于调试的目的,可以使用debug级别,但此级别只有在编译nginx时使用了--with-debug选项才有效;

    #debug | info | notice | warn | error | crit | alert | emerg error_log /opt/nginx/logs/nginx_error.log crit;

    pid /opt/nginx/logs/nginx.pid; worker_rlimit_nofile 65535;                           

    events {    

    use epoll;    

    #每个进程允许的最多连接数, 理论上每台nginx 服务器的最大连接数为worker_processes*worker_connections。    

    worker_connections 6000;

    }

    http {    

    include mime.types;    

    default_type application/octet-stream;    

    server_names_hash_bucket_size 3526;    

    server_names_hash_max_size 4096;    

    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    /opt/nginx/logs/access.log main;    

    sendfile on;    

    tcp_nopush on;

    #常连接配置    

    keepalive_timeout 60;    

    keepalive_requests 200;

    #读取http请求报文    

    client_header_timeout 120;    

    client_body_timeout 120;    

    #客户端请求头部的缓冲区大小,这个可以根据你的系统分页大小来设置,一般一个请求头的大小不会超过1k,不过由于一般系统分页都要大于1k,所以这里设置为分页大小。分页大小可以用命令getconf PAGESIZE 取得。    

    client_header_buffer_size 4k;    

    large_client_header_buffers 8 4k;

    #响应报文    

    send_timeout 120;   

    #压缩配置    

    gzip on;    

    gzip_min_length 1k;    

    gzip_buffers 4 8k;    

    gzip_comp_level 5;    

    gzip_http_version 1.1;    

    gzip_types text/plain application/x-javascript text/css text/htm application/xml;

    open_file_cache max=102400 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 1;

          #此server配置 ip访问403,本机查看ngx_status

          server{          

         listen *:80 default_server;
              server_name _;
              #return 403;
              root /tmp;
              location /ngx_status{
                  stub_status on;
                  access_log off;
                  allow 127.0.0.1;
                  deny all;
             }

        }      

    include /opt/nginx/conf/vhosts/*.conf;

    }

  • 相关阅读:
    [学习笔记]康托展开
    [模板]平衡树
    [题解]涂色
    [学习笔记]Lucas定理
    欧拉定理及其证明
    一些杂题(排列组合
    swift 动画合集
    UIDynamicAnimator UIKit动力学
    swift 当协议遇见了泛型
    Swift 协议
  • 原文地址:https://www.cnblogs.com/hanxiaohui/p/8487454.html
Copyright © 2020-2023  润新知