• nginx配置文件详解


    nginx配置文件

    user nginx;                                             指定 nginx 运行的用户及用户组
    worker_processes 4;                                     启动进程数量==CPU核心的数量
    pid logs/nginx162.pid;                       PID 文件
    error_log logs/nginx_error.log crit;             定义日志文件及级别
    
    events {
    use epoll;                                              事件处理模型,可以不指定,Nginx会自动选择最佳的
    worker_connections 100000;                              单个进程最大并发量
    --    ps:仅修改Nginx并发数是无效的,还需要系统参数
    --    cat /etc/security/limits.conf
    --    * soft nofile 100000
    --    * hard nofile 100000
    }
    
    http {
    include mime.types;                                     设定mime类型
    default_type application/octet-stream;              默认文件类型
    server_tokens off;                          不显示 Nginx 具体版本号
    charset UTF-8;                                        设置字符集
    proxy_intercept_errors on;                              当Client请求时,若tomcat抛出404,nginx会跳转到一个固定页面
    open_file_cache max=131072 inactive=60s;            打开文件缓存数量及缓存时间
    open_file_cache_valid 80s;                              多久检查一次缓存的有效信息
    open_file_cache_min_uses 1;                             访问次数超过 1 次才被缓存
    server_names_hash_bucket_size 128;                      服务器名字的hash表大小
    client_header_buffer_size 4k;                           默认请求包头信息的缓存
    large_client_header_buffers 8 128k;                     大请求包头部信息的缓存个数及容量
    client_max_body_size 1500m;                             上传文件大小,PHP默认上传文件不超过2M
    sendfile on;                                            开启高效文件传输模式
    tcp_nopush on;                              当包累计到一定大小才发送,防止网络阻塞,和 tcp_nodelay “互斥”
    fastcgi_intercept_errors on;                   开启传递4xx或5xx错误信息到客户端,反向代理用proxy_intercept_errors on 
    keepalive_timeout 60;                         保持会话的超时时间,只有tcp_nodelay on,keepalive_timeout才有效
    tcp_nodelay on;                             防网络阻塞
    gzip on;                                  开启gzip压缩功能  
    gzip_min_length 1k;                          最小压缩的容量
    gzip_buffers 4 16k;                         压缩缓存大小
    gzip_http_version 1.0;                       压缩版本
    gzip_comp_level 2;                          压缩级别
    gzip_types text/plain application/x-javascript text/css application/xml;    压缩类型
    gzip_vary on;                                       给代理服务器加个vary标识,判断客户端浏览器是否要压缩,IE6不支持gzio压缩
    
    include limit/limit_zone.conf                   限制配置文件
    include cache/cache_zone.conf;                   缓存配置文件
    include conf/vhost/*.conf;                    虚拟主机配置文件
    }

    nginx

  • 相关阅读:
    Kubernetes中部署MySQL
    内置函数-format()
    Jenkins-deploymnt
    一次遇到too many open files的解决详情
    一次nginx问题记录
    kickstart自动化安装系统
    Maven —— 命令行清除编译打包
    CURL 发送POST请求
    mysql的my.cnf配置参考
    利用nginx实现生产和灰度环境流量切换
  • 原文地址:https://www.cnblogs.com/wuhg/p/9448732.html
Copyright © 2020-2023  润新知