美文网首页
nginx配置详解 、nginx负载配置详解

nginx配置详解 、nginx负载配置详解

作者: 醉青风 | 来源:发表于2020-03-26 16:39 被阅读0次

    #user nobody;

    worker_processes  1;

    #error_log  logs/error.log;

    #error_log  logs/error.log  notice;

    #error_log  logs/error.log  info;

    #pid        logs/nginx.pid;

    events {

        worker_connections  10240;  // 设置最大连接数

    accept_mutex on;  #设置网路连接序列化,防止惊群现象发生,默认为on

        multi_accept on;  #设置一个进程是否同时接受多个网络连接,默认为off

        #use epoll;      #事件驱动模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport

    }

    http {

        include      mime.types; #文件扩展名与文件类型映射表

        default_type  application/octet-stream;  #默认文件类型,默认为text/plain

        sendfile        on;  #允许sendfile方式传输文件,默认为off,可以在http块,server块,location块。

        #tcp_nopush    on;

        keepalive_timeout  65;  #连接超时时间,默认为75s,可以在http,server,location块。

    client_max_body_size 2048m;  #限制请求体的大小,若超过所设定的大小,返回413错误。

        #gzip  on;

    #access_log off; #取消服务日志   

    ##################页面单独配置######################### 

    server {

    keepalive_requests 120; #单连接请求上限次数。

        listen 905;  #监听端口

        server_name  127.0.0.1; #监听地址

    root  E:/01_yysws/yysws_html/portal_site/dist;    #根目录

      location /{  #  ~*^.+$  请求的url过滤,正则匹配,~为区分大小写,~*为不区分大小写。

          index  index.html index.htm;

                #deny 127.0.0.1;  #拒绝的ip

                #allow 172.18.5.54; #允许的ip   

        }

    }

    ########################################################## 

    ##################地址负载代理设置######################### 

    upstream wxj_app {  //地址设置

            server 127.0.0.1:902 weight=1 fail_timeout=5;  //代理地址一

    server 47.101.132.243:902 weight=1 fail_timeout=5;  //代理地址二

            ip_hash;

      }

      server {

              listen      906;  #  对外地址(相当于把 127.0.0.1:902 和 47.101.132.243:902  合成一个地址  127.0.0.1:906)

              server_name  127.0.0.1;

        location / {

            root  html;

            index  index.html index.htm;

      proxy_connect_timeout  60;

      proxy_send_timeout      600;

      proxy_read_timeout      600;

            proxy_pass  http://wxj_app;  //  地址

      client_max_body_size 1024m;

              }

              error_page  500 502 503 504  /50x.html;

              location = /50x.html {

                  root  html;

              }

          }

    #############################################

    ####################文件配置#########################

        server {

            listen      8100; #监听端口

            server_name  127.0.0.1; #监听地址

    root  E:/zhjy/fileUpload/;  #根目录

            location / {

                try_files $uri $uri/ @router;

                index index.html;

            }

    location @router {

    rewrite ^.*$ /index.html last;

    }

    error_page  500 502 503 504  /50x.html;

            location = /50x.html {

                root  html;

            }

        }

    #############################################

    }

    相关文章

      网友评论

          本文标题:nginx配置详解 、nginx负载配置详解

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