用nginx做weblogic的前端负载均衡器


## set uid and gid of process
user webproxy ngboss;

## how many process will be started
worker_processes 10;

## worker_cpu_affinity define
worker_cpu_affinity 000000000100 000000001000 000000010000 000000100000 000001000000 000010000000 000100000000 001000000000 010000000000 100000000000;

## how many open files will be allowd of each process
worker_rlimit_nofile 51200; 

## error log defind
error_log  logs/error.log crit;

## save master process-id in file
pid        logs/nginx.pid;

events {
	## powered by epoll, good!
	use epoll;
	worker_connections 51200; 
}

http {
	include       mime.types;
	default_type  text/html;

	## access log format defind
	log_format  main  '$remote_addr [$time_local] $request $status $body_bytes_sent';

	## access log defind
	access_log  logs/access.log  main;

	## fast send file system call, good!
	sendfile		on;
	tcp_nopush		on;
	tcp_nodelay			on;
	client_body_buffer_size 	1024k;
	proxy_connect_timeout		600;
	proxy_read_timeout		600;	
	proxy_send_timeout		600;
	proxy_buffer_size		8k;
	proxy_buffers			4 32k;
	proxy_busy_buffers_size		64k;
	proxy_temp_file_write_size	1024k;
	
	## set connection timeout (by second)
	keepalive_timeout  30;

	## gzip setting begin.
	gzip			on;
	gzip_min_length		1k;
	gzip_buffers		4 16k;
	gzip_http_version	1.1;
	gzip_comp_level		9;
	gzip_vary		off;
	gzip_types		text/plain text/javascript text/css text/xml application/xml;
	## gzip setting end.

	output_buffers		4 32k;
	postpone_output		1460;

	client_header_buffer_size		128k;
	large_client_header_buffers		4 256k;

	## default encoding
        # charset GBK;

	## app redirect && load-balancer start
	# ngboss cluster
	upstream ngboss_cluster {
		ip_hash;
		server 10.238.15.65:7101;
		server 10.238.15.66:7201;
		server 10.238.15.67:7301;
		server 10.238.15.68:7401;
	}
	# saleserv cluster
	upstream saleserv_cluster {
		ip_hash;
		server 10.238.15.65:8181;
		server 10.238.15.66:8281;
		server 10.238.15.67:8381;
		server 10.238.15.68:8481;
		server 10.238.15.65:8182;
		server 10.238.15.66:8282;
		server 10.238.15.67:8382;
		server 10.238.15.68:8482;
	}
	# acctmanm cluster
	upstream acctmanm_cluster {
		ip_hash;
		server 10.238.15.65:8191;
		server 10.238.15.66:8291;
		server 10.238.15.67:8391;
		server 10.238.15.68:8491;
		server 10.238.15.65:8192;
		server 10.238.15.66:8292;
		server 10.238.15.67:8392;
		server 10.238.15.68:8492;
	}
	# custmanm cluster
	upstream custmanm_cluster {
		ip_hash;
		server 10.238.15.65:8111;
		server 10.238.15.66:8211;
	}
	# groupserv cluster
	upstream groupserv_cluster {
		ip_hash;
		server 10.238.15.65:8183;
		server 10.238.15.66:8283;
	}
	# salemanm cluster
	upstream salemanm_cluster {
		ip_hash;
		server 10.238.15.65:8121;
		server 10.238.15.66:8221;
	}
	# chnlmanm cluster
	upstream chnlmanm_cluster {
		ip_hash;
		server 10.238.15.65:8101;
		server 10.238.15.66:8201;
	}
	# resmanm cluster
	upstream resmanm_cluster {
		ip_hash;
		server 10.238.15.65:8131;
		server 10.238.15.66:8231;
	}
	# prodmcrm prodmbil bilmanm cluster
	upstream prodmanm_cluster {
		server 10.238.15.66:8261;
	}
	# copmanm cluster
	upstream copmanm_cluster {
		server 10.238.15.66:8271;
	}
	# sysmanm cluster
	upstream sysmanm_cluster {
		ip_hash;
		server 10.238.15.65:8141;
		server 10.238.15.66:8241;
	}
	# statmanm cluster
	upstream statmanm_cluster {
		ip_hash;
		server 10.238.15.65:8151;
		server 10.238.15.66:8251;
	}
	## app redirect && load-balancer end

	server {
		listen       10.238.15.101:18080;
		server_name  10.238.15.101;
		proxy_set_header   X-Forwarded-For  $remote_addr;
                # charset GBK;

		location /download {
			root html;
			proxy_redirect off;
		}
		location /saleserv {
                        if ($request_uri ~* ".*\.(js|css|gif|jpg|jpeg|png|bmp|swf)$") {
                                proxy_pass http://saleserv_cluster;
                                expires max;
                                break;
                        }
			proxy_pass	http://saleserv_cluster;
			proxy_redirect	off;
		}

		location /acctmanm {
                        if ($request_uri ~* ".*\.(js|css|gif|jpg|jpeg|png|bmp|swf)$") {
                                proxy_pass http://acctmanm_cluster;
                                expires max;
                                break;
                        }
			proxy_pass	http://acctmanm_cluster;
			proxy_redirect	off;
		}
		location /custmanm {
                        if ($request_uri ~* ".*\.(js|css|gif|jpg|jpeg|png|bmp|swf)$") {
                                proxy_pass http://custmanm_cluster;
                                expires max;
                                break;
                        }
			proxy_pass	http://custmanm_cluster;
			proxy_redirect	off;
		}
		location /groupserv {
                        if ($request_uri ~* ".*\.(js|css|gif|jpg|jpeg|png|bmp|swf)$") {
                                proxy_pass http://groupserv_cluster;
                                expires max;
                                break;
                        }
			proxy_pass	http://groupserv_cluster;
			proxy_redirect	off;
		}
		location /salemanm {
                        if ($request_uri ~* ".*\.(js|css|gif|jpg|jpeg|png|bmp|swf)$") {
                                proxy_pass http://salemanm_cluster;
                                expires max;
                                break;
                        }
			proxy_pass	http://salemanm_cluster;
			proxy_redirect	off;
		}
		location /chnlmanm {
                        if ($request_uri ~* ".*\.(js|css|gif|jpg|jpeg|png|bmp|swf)$") {
                                proxy_pass http://chnlmanm_cluster;
                                expires max;
                                break;
                        }
			proxy_pass	http://chnlmanm_cluster;
			proxy_redirect	off;
		}
		location /resmanm {
                        if ($request_uri ~* ".*\.(js|css|gif|jpg|jpeg|png|bmp|swf)$") {
                                proxy_pass http://resmanm_cluster;
                                expires max;
                                break;
                        }
			proxy_pass	http://resmanm_cluster;
			proxy_redirect	off;
		}
		location /prodmcrm {
                        if ($request_uri ~* ".*\.(js|css|gif|jpg|jpeg|png|bmp|swf)$") {
                                proxy_pass http://prodmanm_cluster;
                                expires max;
                                break;
                        }
			proxy_pass	http://prodmanm_cluster;
			proxy_redirect	off;
		}
		location /prodmbil {
                        if ($request_uri ~* ".*\.(js|css|gif|jpg|jpeg|png|bmp|swf)$") {
                                proxy_pass http://prodmanm_cluster;
                                expires max;
                                break;
                        }
			proxy_pass	http://prodmanm_cluster;
			proxy_redirect	off;
		}
		location /bilmanm {
                        if ($request_uri ~* ".*\.(js|css|gif|jpg|jpeg|png|bmp|swf)$") {
                                proxy_pass http://prodmanm_cluster;
                                expires max;
                                break;
                        } 
			proxy_pass	http://prodmanm_cluster;
			proxy_redirect	off;
		}
		location /copmanm {
                        if ($request_uri ~* ".*\.(js|css|gif|jpg|jpeg|png|bmp|swf)$") {
                                proxy_pass http://copmanm_cluster;
                                expires max;
                                break;
                        } 
			proxy_pass	http://copmanm_cluster;
			proxy_redirect	off;
		}
		location /sysmanm {
                        if ($request_uri ~* ".*\.(js|css|gif|jpg|jpeg|png|bmp|swf)$") {
                                proxy_pass http://sysmanm_cluster;
                                expires max;
                                break;
                        } 
			proxy_pass	http://sysmanm_cluster;
			proxy_redirect	off;
		}
		location /statmanm {
                        if ($request_uri ~* ".*\.(js|css|gif|jpg|jpeg|png|bmp|swf)$") {
                                proxy_pass http://statmanm_cluster;
                                expires max;
                                break;
                        } 
			proxy_pass	http://statmanm_cluster;
			proxy_redirect	off;
		}
		location /nginxstatus {
			stub_status on;
			access_log off;
			allow all;
		}
		location / {
                        if ($request_uri ~* ".*\.(js|css|gif|jpg|jpeg|png|bmp|swf)$") {
                                proxy_pass http://ngboss_cluster;
                                expires max;
                                break;
                        } 
			proxy_pass	http://ngboss_cluster;
			proxy_redirect	off;
		}
		
		# redirect server error pages to the static page /50x.html
		error_page 500 502 503 504  /50x.html;
		location = /50x.html {
			root   html;
		}
	}
}

猜你喜欢

转载自stevenos.iteye.com/blog/584463