zoukankan      html  css  js  c++  java
  • nginx 几个常用的标准模块介绍

    • ngx_http_ssl_module(https)
    1:指明是否启用的虚拟主机的ssl功能
    ssl on | off;
     
    2:指明虚拟主机使用的证书文件
    ssl_certificate /usr/local/nginx/conf/cert.pem;
     
    3:指明虚拟主机使用的私钥文件
    ssl_certificate_key /usr/local/nginx/conf/cert.key;
     
    4:指明SSL的协议版本
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
     
    5:指明ssl会话的缓存机制
    ssl_session_cache shared:SSL:10m;
    shared:表明是worker共享的缓存
    name:缓存的名称
    size:缓存大小的单位是字节,每1MB内存空间可以缓存4000个会话
     
    6:指明ssl会话超时时长
    ssl_session_timeout 10m;
    

      

    • ngx_http_log_module(日志)
    1:访问日志路径,记录类型,是否压缩,多长时间刷新一次缓冲
    access_log /path/to/log.gz combined gzip flush=5m;
     
    2:指定日志记录类型
    log_format combined '$remote_addr - $remote_user [$time_local] '
    '"$request" $status $body_bytes_sent '
    '"$http_referer" "$http_user_agent"';
     
    3:指定日志缓冲的信息,也就是指定文件描述符
    open_log_file_cache max=1000 inactive=20s valid=1m min_uses=2;
    

      

     
    • Nginx使用proxy_pass和fastcgi_pass实现单台主机的动静分离(PHP以httpd模块方式运行)
    location ~* .html$ {
     
    proxy_pass http://192.168.23.11:8080;
     
    }
     
    location ~* .php$ {
     
    proxy_pass http://192.168.23.12;
     
    }
    

      

     
    ngx_http_headers_module模块详解(这个模块可以给响应报文添加自定义首部)
    • 可以在location段中添加
      # 添加一个响应头,指明响应请求的服务器的主机名
      add_header X-Server $server_name;
       
      # 指明缓存的超时时长,超过这段时间缓存服务器就会向后端真实服务器请求,并更新缓存
      expires 24h;
       
      # 告知客户端,响应客户端请求的报文是缓存中加载的,还是后端服务器响应的
      add_header X-cache $uptream_cache_status;
      

        


  • 相关阅读:
    WindowsManager 程序(一) 控制窗口的程序
    SQLServer导入导出资料的方法
    CSS收集(1)
    SQLReporting Service
    WindowsManager 程序(二)
    Microsoft 预发行软件 Visual Studio Team System 2008 测试版 2 Team Suite
    Ajax Pro 使用
    一个获取文件的ICON类
    MyCodeBar我的代码片段管理工具
    ADSL自动断拨号类
  • 原文地址:https://www.cnblogs.com/liu1026/p/7537948.html
Copyright © 2011-2022 走看看