宝塔负载均衡 - 小白的记事本

小白写过的小教程

宝塔负载均衡

upstream plm {
        sticky;
        server  10.0.1.162:80;
        server  10.0.1.163:80;
    }

    server {
        listen   80;
        server_name  localhost plmfzjh.jangho.com;

        #charset koi8-r;
        access_log   /dev/null;
        error_log  /dev/null;
	    
        #access_log  logs/host.access.log  main;

        location / {
            #root   html;
            #index  index.html index.htm;
            proxy_pass         http://plm;
            proxy_set_header   Host             $http_host;
            proxy_set_header   X-Forwarded-For        $remote_addr;
            proxy_set_header   X-Real-User_Client_Access  $remote_user;

            client_max_body_size     2048m;
            proxy_connect_timeout       15s;
            proxy_read_timeout          600s;
            proxy_send_timeout          600s;

            if (-d $request_filename){ rewrite ^/(.*)([^/])$ /$1$2/ permanent; }

}

		
        location ~ \.(gif|jpg|jpeg|png|bmp|ico)$ {
		    access_log off;
            proxy_set_header   Host				$http_host;
            proxy_set_header   X-Forwarded-For  $remote_addr;
            proxy_pass		   http://plm;

            expires 1d; 
        }



        location /cstatus {
            stub_status on;
            access_log off;
        }

        #error_page  404              /404.html;
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        
    }
分享