您的位置:首页 > 运维架构 > Tomcat

nginx+tomcat集群配置

2015-07-26 17:21 591 查看
user nobody nobody;

#cpu个数,可以按照实际服务器来计算

worker_processes 8;

worker_rlimit_nofile 51200;

events {

use epoll;

#连接数

worker_connections 8192 ;

}

http {

include mime.types;

default_type application/octet-stream;

server_names_hash_bucket_size 128;

# access_log off;

# access_log logs/access.log;

#缓存的时间,(可以根据不同文件设置不同时间)

# expires 2h;

tcp_nodelay on;

keepalive_timeout 30;

gzip on;

gzip_min_length 10;

gzip_buffers 4 8k;

gzip_http_version 1.1;

gzip_types text/plain application/x-javascript text/css text/html application/xml;

sendfile on;

tcp_nopush on;

reset_timedout_connection on;

client_max_body_size 30m;

#设定负载均衡列表

upstream backend

{

server 219.142.50.103:8080;

server 219.142.50.103:9080;
ip_hash;  #ip粘滞

}

#设定虚拟主机
server {

listen 80;

server_name crtvsvs.ouchn.edu.cn;

#对 / 所有做负载均衡(本机nginx采用完全转发,所有请求都转发到后端的tomcat集群)

location / {

root /web/www ;

index index.jsp index.htm index.html login.html;

proxy_redirect off;

#保留用户真实信息

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_pass http://backend; 
}

}

}

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: