window+nginx1.3.9+tomcat 6.0分布式部署系统

第一次做分布式部署系统,花了很多时间,网了不少资料,还好,成了;

环境:

tomcat6.0:主机和vm上的两套tomcat的容器的配置文件server.xml的配置是一样的:

在</host>标签前加

<ContextdocBase="d:\Workspaces\MyEclipse8.6\wangpu\WebRoot"path=""reloadable="true"></Context>

vm下的window部署了一套系统;

主机(192.168.1.111)上部署了一套

nginx部署在vm下的

主要是nginx的配置文件nginx.conf;配置如下:

#usernobody;

worker_processes1;

#error_loglogs/error.log;

#error_loglogs/error.lognotice;

#error_loglogs/error.loginfo;

#pidlogs/nginx.pid;

events{

worker_connections1024;

}

http{

includemime.types;

default_typeapplication/octet-stream;

#定义日志格式

log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'

'$status$body_bytes_sent"$http_referer"'

'"$http_user_agent""$http_x_forwarded_for"';

access_loglogs/access.logmain;

sendfileon;

#tcp_nopushon;

#keepalive_timeout0;

keepalive_timeout65;

#gzipon;

upstreambackend{

serverlocalhost:8080;

server192.168.1.111:8080;

#ip_hash;

}

server{

listen9999;

server_namelocalhost;

#charsetkoi8-r;

#access_loglogs/host.access.logmain;

location/{

roothtml;

indexindex.htmlindex.htm;

includeproxy.conf;#这个文件是我新建的,要导入

}

#error_page404/404.html;

#redirectservererrorpagestothestaticpage/50x.html

#

error_page500502503504/50x.html;

location=/50x.html{

roothtml;

}

#proxythePHPscriptstoApachelisteningon127.0.0.1:80

#

#location~\.php${

#proxy_passhttp://127.0.0.1;

#}

#passthePHPscriptstoFastCGIserverlisteningon127.0.0.1:9000

#

#location~\.php${

#roothtml;

#fastcgi_pass127.0.0.1:9000;

#fastcgi_indexindex.php;

#fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name;

#includefastcgi_params;

#}

#denyaccessto.htaccessfiles,ifApache'sdocumentroot

#concurswithnginx'sone

#

#location~/\.ht{

#denyall;

#}

}

#anothervirtualhostusingmixofIP-,name-,andport-basedconfiguration

#

#server{

#listen8000;

#listensomename:8080;

#server_namesomenamealiasanother.alias;

#location/{

#roothtml;

#indexindex.htmlindex.htm;

#}

#}

#HTTPSserver

#

#server{

#listen443;

#server_namelocalhost;

#sslon;

#ssl_certificatecert.pem;

#ssl_certificate_keycert.key;

#ssl_session_timeout5m;

#ssl_protocolsSSLv2SSLv3TLSv1;

#ssl_ciphersHIGH:!aNULL:!MD5;

#ssl_prefer_server_cipherson;

#location/{

#roothtml;

#indexindex.htmlindex.htm;

#}

#}

}

上述配置文件中需要引入的文件proxy.conf内容:

proxy_passhttp://backend;

proxy_redirectoff;

proxy_set_headerHost$host;

proxy_set_headerX-Real-IP$remote_addr;

proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;

client_max_body_size10m;

client_body_buffer_size128k;

proxy_connect_timeout90;

proxy_send_timeout90;

proxy_read_timeout90;

proxy_buffer_size4k;

#proxy_buffers4k;#此处放开会报错,暂时没搞明白原因

proxy_busy_buffers_size8k;

proxy_temp_file_write_size64k;

相关推荐