环境: 本地win10 ,二手centos7
win10
ip :192.168.1.102
嵌入式tomcat 起两个应用 端口8081 和8082;
项目:书上弄下来的项目 人事管理
nginx1.4.5
host修改 把192.168.1.102 映射到www.gan2.com
192.168.200.128 www.gan.com
192.168.1.102 www.gan2.com
nginx.conf配置
修改nginx 日志格式 方便看 请求分发的地址 状态,响应
通过upstream配置把请求分发到8081 和8082台机器 数量比例是1:2
配置proxy_pass 所有请求都会先到 nginx反向代理机器上 再分发
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" $upstream_response_time $upstream_addr $upstream_status';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
upstream hrmSSM {
#server 127.0.0.1:8001 weight=2;
#server 127.0.0.1:8002 weight=1;
server 127.0.0.1:8081 weight=1;
server 127.0.0.1:8082 weight=2;
}
server {
listen 80;
server_name www.gan2.com;
location / {
proxy_pass http://hrmSSM;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
过程
1.启动 两台tomcat
2.配置host和nginx.conf
3.启动nginx服务
4.访问www.gan2.com/hrmSSM 查看nginx.access 日志 查看分发情况
centos7
3台tomcat 端口8001,8002,8003
安装nginx 。。。。后续