美文网首页
Nginx配置文件

Nginx配置文件

作者: 紫荆秋雪_文 | 来源:发表于2020-06-13 06:18 被阅读0次

    一、Nginx配置文件

    nginx.conf文件包含:

    • 1、全局块:配置影响Nginx全局的命令。如:用户组、Nginx进程pid存放路径,日志存放路径,配置文件引入,允许生成worker process等

    • 2、events块:配置影响nginx服务器或与用户的网络连接。如:每个进程的最大连接数,选取那种事件驱动模型处理连接请求,是否允许同时接受多个网络连接,开启多个网络连接序列化等。

    • 3、http块:可以嵌套多个server,配置代理,缓存,日志定义等绝大多数功能和第三方模块的配置。如文件引入,mime-type定义,日志自定义,是否使用sendifile传输文件,连接超时时间,单连接请求数等。

      • 3.1、http全局快:如upstream,错误页面,连接超时等
      • 3.2、server块:配置虚拟机的相关参数,一个http中可以有多个server
        • 3.2.1、location:配置请求的路由,以及各种页面的处理情况
        • 3.2.2、location
        • 3.2.3、...
    • nginx.conf

    user  nginx;
    worker_processes  1;
    
    error_log  /var/log/nginx/error.log warn;
    pid        /var/run/nginx.pid;
    
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include       /etc/nginx/mime.types;
        default_type  application/octet-stream;
    
        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  /var/log/nginx/access.log  main;
    
        sendfile        on;
        #tcp_nopush     on;
    
        keepalive_timeout  65;
    
        #gzip  on;
    
        include /etc/nginx/conf.d/*.conf;
    }
    

    相关文章

      网友评论

          本文标题:Nginx配置文件

          本文链接:https://www.haomeiwen.com/subject/etbmtktx.html