1. Nginx构建Tomcat集群Demo
通过Nginx的upstream模块构建三台Tomcat组成的集群,首先在nginx.conf文件中添加如下内容:
upstream youpin-server {
server 192.168.1.173:8080;
server 192.168.1.174:8080;
server 192.168.1.175:8080;
}
server {
listen 80;
server_name www.youpin.com;
location / {
proxy_pass http://youpin-server
}
}
- youpin-server是个字符串,随便命名,但是在location块中必须得加上前缀http://来实现映射;