nginx实现nginx/tomcat负载均衡
准备三台centos7虚拟机,全部安装nginx或者tomcat
虚拟机A 10.0.3.46 在index.html 中添加10.0.3.46作为标志
虚拟机B 10.0.3.66 使用这台做负载均衡
虚拟机C 10.0.3.110 默认页面不做修改
一.nginx之间的负载均衡:
[root@localhost nginx]# cat conf/nginx.conf|grep -v '#'|grep -v ^$
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream webservers { #这里是新添加上去的
server 10.0.3.110 weight=1; #server ip地址 weight=权重
server 10.0.3.46 weight=1;
}
server {
listen 80;
server_name localhost;
location / { #把原来括号里面的内容注释,添加以下内容
proxy_pass http://webservers; #设置代理?webservers与前面 upstream后面的命名一致
proxy_set_header x-Real-IP $remote_addr; #这个不懂什么意思
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
[root@localhost nginx]#
第一次进去

刷新之后

二:实现tomcat之间的负载均衡
[root@localhost nginx]# cat conf/nginx.conf|grep -v '#'|grep -v ^$
worker_processes ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ;
upstream webservers { #这里是新添加上去的,与nginx不同,只需要在ip后面添加端口即可
server 10.0.3.110: weight=; #server ip地址 weight=权重
server 10.0.3.46: weight=;
}
server {
listen ;
server_name localhost;
location / { #把原来括号里面的内容注释,添加以下内容
proxy_pass http://webservers; #设置代理?webservers与前面 upstream后面的命名一致
proxy_set_header x-Real-IP $remote_addr; #这个不懂什么意思
}
error_page /50x.html;
location = /50x.html {
root html;
}
}
}
[root@localhost nginx]#
nginx实现nginx/tomcat负载均衡的更多相关文章
- centos 安装nginx + 多个tomcat负载均衡
今天在centos上安装了两个tomcat和nginx,进行配置.今天记录的只是最基本的实现测试.(不包含使用redis进行session共享) Nginx 是一款轻量级的Web 服务器/反向代理服务 ...
- 使用apache和nginx代理实现tomcat负载均衡及集群配置详解
实验环境: 1.nginx的代理功能 nginx proxy: eth0: 192.168.8.48 vmnet2 eth1: 192.168.10.10 tomcat server1: vmnet2 ...
- Linux下nginx+多个Tomcat负载均衡的实现
博主原创,转载请注明. 由于项目需要,共创建了10个Tomcat端,由nginx负责转发.9个Tomcat端口分别是8080,11000,12000,13000,14000,15000,16000,1 ...
- Nginx+tomcat负载均衡时静态页面报404
百度到的问题解决BLOG http://os.51cto.com/art/201204/326843.htm nginx+2台tomcat负载均衡,应用程序已部署,单独访问tomcat时,可以访问到所 ...
- nginx+tomcat负载均衡
最近练习nginx+tomcat负载均衡.根据一些资料整理了大体思路,最终实现了1个nginx+2个tomcat负载均衡. 安装JDK 1>进入安装目录,给所有用户添加可执行的权限 #chmod ...
- Linux下Nginx+Tomcat负载均衡和动静分离配置要点
本文使用的Linux发行版:CentOS6.7 下载地址:https://wiki.centos.org/Download 一.安装Nginx 下载源:wget http://nginx.org/pa ...
- 基于nginx的tomcat负载均衡和集群
要集群tomcat主要是解决SESSION共享的问题,因此我利用memcached来保存session,多台TOMCAT服务器即可共享SESSION了. 你可以自己写tomcat的扩展来保存SESSI ...
- linux+nginx+tomcat负载均衡,实现session同步
linux+nginx+tomcat负载均衡,实现session同步 花了一个上午的时间研究nginx+tomcat的负载均衡测试,集群环境搭建比较顺利,但是session同步的问题折腾了几个小时才搞 ...
- Nginx+keepalived做双机热备加tomcat负载均衡
Nginx+keepalived做双机热备加tomcat负载均衡 环境说明: nginx1:192.168.2.47 nginx2:192.168.2.48 tomcat1:192.168.2.49 ...
- nginx+tomcat负载均衡策略
測试环境均为本地,測试软件为: nginx-1.6.0,apache-tomcat-7.0.42-1.apache-tomcat-7.0.42-2.apache-tomcat-7.0.42-3 利用n ...
随机推荐
- Factory,工厂设计模式,C++描述
body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...
- node 慕课笔记
global global.testVar2 = 200; 在别的文件中可以任意调用到 因为global是全局变量相当于js的window一样的
- datatabale 服务器分页
转载:http://blog.csdn.net/angelvyvyan/article/details/51783272$(document).ready( function() { $('#tabl ...
- Xilinx SDK编译Microblaze时出错
reference:http://www.eeboard.com/evaluation/digilent-cmod-a7-fpga/9/ 在vivado 2015.4中创建microblaze软核,l ...
- docker从初识到深入
1:使用docker有哪些优势: 更快交付你的应用(Faster delivery of your applications) 让部署和测试更简单(Deploying and scaling more ...
- NioEventLoop中的thread什么时候启动
在构造函数中被赋值,并传入传入runnable接口,方法里面循环select,然后处理找到的key 但是这个thread是什么时候被start的呢? 在bootstrap bind的逻辑里,后半部分是 ...
- [Spring-AOP-XML] 利用Spirng中的AOP和XML进行事务管理
Spring中的AOP进行事务管理有三种方式 A.自定义事务切面 利用AspectJ来编写事务,我们一般把这个切面作用在service层中.其他代码在下面 编写一个Transaction实现类,通过S ...
- 框架:Spring IoC
Spring篇 第二章.Spring IoC简介 一.基本概念 控制反转是一个比较抽象的概念,是Spring框架的核心,用来消减计算机程序的耦合问题. 依赖注入是IoC的另外一种说法,只是从不同的角度 ...
- crontab入门及进阶学习笔记
crontab不是通常意义下的linux指令,它更是一个配置工具.通过这个工具,我们可以为系统定制固定周期的任务. 1.crond和crontab 1) crond:cron服务的守护进程,用于定 ...
- 【Python】数字驱动
#练习1:打开3个网址,每个等3秒钟 urls.txt: http://www.baidu.com http://www.sogou.com http://www.sohu.com main.py: ...