1。修改nginx.conf配置文件,在http大括号中添加如下配置
<>之前,upstream nginx { ,,,,server 192.168.2.140:8080; ,,,,server 192.168.2.136:8080; 以前,}>
2。修改服务器的位置中的配置
<>之前的位置/,{ ,,,proxy_pass , #就是这一行,这里的nginx就是上面upstream 后面的nginx,这是一个名称,请保存两个 ,,,#地方是一致的 ,,,auth_basic ; ,,,auth_basic_user_file /var/用户; ,,,root ,, html; ,,,index , index.html 你可以; }
3。准备两台云服务器地址分别为192.168.2.140和192.168.2.136,并安装apache服务器、端口使用8080
& lt; !——, tomcat1中的index.jsp ——比; & lt; html> ,,,& lt; h3> tomcat1 & lt;/html> & lt; !——, tomcat2中的index.jsp ——比; & lt; html> ,,,& lt; h3> tomcat2 & lt;/html>
5。在浏览器访问http://www.nginx1.com/即可看到配置后的结果,每一次刷新请求不同的apache服务