zoukankan      html  css  js  c++  java
  • Nginx部署文件(一)-nginx.conf文件

    一,默认文件说明

    1.以nginx/1.14.0 (Ubuntu)为例

     1 # 使用的用户和组
     2 user www-data;
     3 # 定义nginx对外提供web服务时的worker进程数
     4 worker_processes auto;
     5 # 指定pid存放的路径,应该记录了nginx守护进程的进程号,是其他进程的父进程id!(如Apache下有PidFile )
     6 pid /run/nginx.pid;
     7 include /etc/nginx/modules-enabled/*.conf;
     8 
     9 events {
    10     worker_connections 768;  # 允许的最大连接数
    11     # multi_accept on;       # 收到一个新连接通知后接受尽可能多的连接
    12 }
    13 
    14 http {
    15 
    16     ##
    17     # Basic Settings 基本设置
    18     ##
    19 
    20     sendfile on;               # 开启sendfile()数据缓冲,请保持默认打开
    21     tcp_nopush on;             # 发送所有头文件
    22     tcp_nodelay on;            # 及时发送数据
    23     keepalive_timeout 65;      # 请求超过时间
    24     types_hash_max_size 2048;  #散列表的冲突率,types_hash_max_size越大,就会消耗更多的内存,但散列key的冲突率会降低,检索速度就更快。
    25     # server_tokens off;       # 关闭在错误页面中的nginx版本数字,有利于安全
    26 
    27     # server_names_hash_bucket_size 64;
    28     # server_name_in_redirect off;
    29 
    30     include /etc/nginx/mime.types;          # 加载MIME类型
    31     default_type application/octet-stream;  # 设置文件使用的默认的MIME-type
    32                                             #charset UTF-8; 设置我们的头文件中的默认的字符集
    33     ##
    34     # SSL Settings SSL设置
    35     ##
    36 
    37     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;  # Dropping SSLv3, ref: POODLE
    38     ssl_prefer_server_ciphers on;
    39 
    40     ##
    41     # Logging Settings 日志设置
    42     ##
    43 
    44     access_log /var/log/nginx/access.log;  # 存储访问日志,关闭这个选项可以让读取磁盘IO操作更快
    45     error_log /var/log/nginx/error.log;    # 记录错误信息
    46 
    47     ##
    48     # Gzip Settings Gzip压缩设置
    49     ##
    50 
    51     gzip on;                  #采用gzip压缩的形式发送数据
    52 
    53     # gzip_vary on;           #针对相同url,可以根据头信息返回压缩和非压缩副本 
    54     # gzip_proxied any;       #any代表压缩所有的请求
    55     # gzip_comp_level 6;      #设置数据的压缩等级,1-9 9最慢
    56     # gzip_buffers 16 8k;     #如果没有设置,默认值是申请跟原始数据相同大小的内存空间去存储gzip压缩结果。
    57     # gzip_http_version 1.1;  #值为1.0和1.1 代表是否压缩http协议1.0,选择1.0则1.0和1.1都可以压缩 
    58     # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;  #设置需要压缩的数据格式
    59 
    60     ##
    61     # Virtual Host Configs 
    62     ##
    63     # 加载conf.d目录与sites-enabled目录下得配置文件
    64     include /etc/nginx/conf.d/*.conf;
    65     include /etc/nginx/sites-enabled/*;
    66 }
    67 
    68 # 邮件代理服务器
    69 #mail {
    70 #    # See sample authentication script at:
    71 #    # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
    72 # 
    73 #    # auth_http localhost/auth.php;
    74 #    # pop3_capabilities "TOP" "USER";
    75 #    # imap_capabilities "IMAP4rev1" "UIDPLUS";
    76 # 
    77 #    server {
    78 #        listen     localhost:110;
    79 #        protocol   pop3;
    80 #        proxy      on;
    81 #    }
    82 # 
    83 #    server {
    84 #        listen     localhost:143;
    85 #        protocol   imap;
    86 #        proxy      on;
    87 #    }
    88 #}

      更多配置属性见:https://blog.csdn.net/xifeijian/article/details/20956605;https://blog.51cto.com/blief/1736849;https://www.iteye.com/blog/phl-1979082

    二,配置实例

    三,负载均衡

    365个夜晚,我希望做到两天更一篇博客。加油,小白!
  • 相关阅读:
    Swift 编程语言新手教程
    标准差(standard deviation)和标准错误(standard error)你能解释一下?
    shell文字过滤程序(十一):paste命令
    java 获取系统变量(环境变量和环境变量)
    MD5算法原理
    受托停止事件冒泡
    搜索引擎优化要领:8条辅助技巧(三)
    几种更新(Update语句)查询的方法
    学习盲点
    2014年同年CFA考试中哪些CFA资料没有变化?
  • 原文地址:https://www.cnblogs.com/qq2806933146xiaobai/p/14541848.html
Copyright © 2011-2022 走看看