windows下設(shè)置nginx負(fù)載均衡-創(chuàng)新互聯(lián)

#user  nobody;
worker_processes1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections1024;
}


http {
    include       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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout0;
    keepalive_timeout65;

    #gzip  on;

 upstream mysvr {
      #weigth參數(shù)表示權(quán)值,權(quán)值越高被分配到的幾率越大   
      #1.down 表示單前的server暫時不參與負(fù)載
      #2.weight 默認(rèn)為1.weight越大,負(fù)載的權(quán)重就越大。     
      #3.backup: 其它所有的非backup機(jī)器down或者忙的時候,請求backup機(jī)器。所以這臺機(jī)器壓力會最輕。  
      #server192.168.1.116  down;
      #server192.168.1.116  backup;
      server192.168.1.128:8080  weight=1;
      server192.168.1.194:8080  weight=2;
    }

    server {
        listen80;        #這里是外網(wǎng)公布的訪問的端口
        server_name122.122.122.122; #這里是外網(wǎng)公布的訪問的公網(wǎng)ip 、或是域名

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location/ {          
        proxy_pass  http://mysvr;   #跟載均衡服務(wù)器的upstream對應(yīng)
        proxy_connect_timeout  5s;  #這里代表其中一臺服務(wù)器宕機(jī)之后把訪問轉(zhuǎn)向另外一臺服務(wù)器
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
             #禁用緩存
        proxy_buffering off;
        }



        #error_page404              /404.html;

        # redirect server error pages to thestatic page /50x.html
        #
        error_page500 502 503 504  /50x.html;
        location= /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on127.0.0.1:80
        #
        #location~ .php$ {
        #    proxy_pass   http://127.0.0.1;        #}

        # pass the PHP scripts to FastCGI server listening on127.0.0.1:9000
        #
        #location~ .php$ {
        #    root           html;
        #    fastcgi_pass127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME/scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files,if Apache's document root        # concurs with nginx's one        #
        #location~ /.ht {
        #    deny  all;
        #}
    }


    # anothervirtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location/ {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location/ {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
nginx相關(guān)命令:windows下設(shè)置nginx負(fù)
載均衡

1)        啟動Nginx:start nginx

創(chuàng)新互聯(lián)是一家專注于網(wǎng)站制作、成都網(wǎng)站設(shè)計與策劃設(shè)計,于田網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)10余年,網(wǎng)設(shè)計領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:于田等地區(qū)。于田做網(wǎng)站價格咨詢:18982081108

2)        停止Nginx:nginx -s stop

3)        修改配置后重啟:nginx -s reload

名稱欄目:windows下設(shè)置nginx負(fù)載均衡-創(chuàng)新互聯(lián)
URL網(wǎng)址:http://muchs.cn/article42/dhgdec.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、品牌網(wǎng)站建設(shè)、全網(wǎng)營銷推廣、云服務(wù)器企業(yè)網(wǎng)站制作、商城網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)