2013-10-10 12:43:01
来 源
kejihao
Nginx
这里分享一下Nginx+Tomcat负载均衡集群配置,希望对于初学Nginx服务器相关的朋友有帮助,更多Nginx安装、配置、报错处理等资源请本站内搜索。。

user nginx;

worker_processes 10;

worker_rlimit_nofile 100000;

error_log

/var/log/nginx/error.log;

#error_log /var/log/nginx/error.log notice;

#error_log /var/log/nginx/error.log info;

pid /var/run/nginx.pid;

events {

worker_connections 1024;

use epoll;

}

http {

include /etc/nginx/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 /var/log/nginx/access.log main;

sendfile on;

tcp_nopush on;

tcp_nodelay on;

server_tokens off;

gzip on;

gzip_static on;

gzip_comp_level 5;

gzip_min_length 1024;

keepalive_timeout 65;

limit_conn_zone $binary_remote_addr zone=addr:10m;

# Load config files from the /etc/nginx/conf.d directory

include /etc/nginx/conf.d/*.conf;

upstream www.wp.com {

#此处为轮询策略 换成你自己的tomcat地址

#可以根据自己的需求配置多个tomcat,当某个地址无效时,nginx会自动切换

server 192.168.5.206:8081;

server 192.168.5.206:8082;

}

server {

#配置对应的端口与域名

listen 80;

server_name www.wp.com;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {

root html;

index index.html index.htm;

#配置上面的server name

proxy_pass http://www.wp.com;

proxy_set_header X-Real-IP $remote_addr;

}

location ~ ^/(WEB-INF)/ {

deny all;

}

error_page 404 /404.html;

location = /404.html {

root /usr/share/nginx/html;

}

# redirect server error pages to the static page /50x.html

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root /usr/share/nginx/html;

}

}

}

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。