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

本文深入探讨了NGINX的高级配置参数,包括进程管理、CPU亲和性、文件打开限制、错误日志、PID文件、事件监听、HTTP模块设置等,详细解释了如何优化服务器性能、实现高效负载均衡和实现应用级路由。通过实例展示了如何配置NGINX以适应复杂的应用场景,包括不同服务集群的负载均衡、文件缓存、压缩、访问日志记录、代理转发等功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



## 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;
}
}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值