基本架构:

nginx(192.168.116.198)

client        --->keepalived(116.200)      ------> tomcat (192.168.116.101,192.168.116.100)

nginx(192.168.116.199)

keepalived的配置文件/etc/keepalived/keepalived.conf:

global_defs {
notification_email {
root@node2
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id nginx2
}

vrrp_script chk_nginx {
script "/server/scripts/chk_nginx.sh"
interval 2
fall 2
rise 1
}

vrrp_instance VI_1 {

track_script {
chk_nginx
}
state BACKUP
interface eth0
virtual_router_id 61
priority 90
nopreempt
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.116.200
}
}

###########################

#!/bin/bash
#check service of nginx is ok
/usr/bin/netstat -anlp |grep -w '0.0.0.0:9443' >/dev/null 2>&1

##################################################

前端nginx配置文件:

/etc/nginx/nginx.conf

worker_processes 3;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream shoudian_http{
ip_hash;
server 192.168.116.100:9000;
# server 192.168.116.101:9000;
}
upstream shoudianhttps {
server 192.168.116.100:9443 weight=10;
# server 192.168.116.101:9443 weight=10;
}
server {
listen 9000;
server_name shoudian_http;
location / {
proxy_pass http://shoudian_http;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
server {
listen 9443;
server_name localhost;

ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
ssl_session_timeout 5m;
location / {
proxy_pass https://shoudianhttps;
}
access_log /etc/nginx/logs/access.log;
error_log /etc/nginx/logs/error.log;
}

}

#后端tomcat的访问方式

curl https://192.168.116.100:9443/

curl http://192.168.116.100:9000/

keepalived + nginx(负载均衡反向代理HTTP,https) + tomcat(HTTP,https)的更多相关文章

  1. nginx负载均衡(反向代理)

    6,安装nginx 6.1 依赖库安装  要安装在root根目录里,不要装在虚拟环境里面 yum install gcc-c++ pcre pcre-devel zlib zlib-devel ope ...

  2. 架构之Nginx(负载均衡/反向代理)

    Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器 ,也是一个 IMAP/POP3/SMTP 代理 服务器 . Nginx 是由 Igor Sys ...

  3. nginx 负载均衡 反向代理

    nginx 通过方向代理实现负载均衡,负载均衡是大流量网站要做的措施,单从字面上的意思来理解为N台服务器平均分担负载,不会因为某一台服务器负载高宕机而影响用户访问网站,负载均衡至少需要三台服务器, 既 ...

  4. Nginx负载均衡反向代理 后端Nginx获取客户端真实IP

    Nginx 反向代理后,后端Nginx服务器无法正常获取客户端的真实IP nginx通过http_realip_module模块来实现的这需要重新编译,如果提前编译好了就无需重新编译了1,重新编译ng ...

  5. Nginx负载均衡反向代理

    http{ upstream test.com { server 118.118.66.88:8080; } server { listen 80; server_name www.test.com; ...

  6. Nginx服务器部署 负载均衡 反向代理

    Nginx服务器部署负载均衡反向代理 LVS Nginx HAProxy的优缺点 三种负载均衡器的优缺点说明如下: LVS的优点: 1.抗负载能力强.工作在第4层仅作分发之用,没有流量的产生,这个特点 ...

  7. Nginx HTTP负载均衡/反向代理的相关参数测试

    原文地址:http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/03/15/1984976.html 测试目的 (1)弄清楚HTTP Upstr ...

  8. nginx域名转发 负载均衡 反向代理

    公司有三台机器在机房,因为IP不够用,肯定要分出来,所以要建立单IP 多域名的反向代理, 就是当请求www.abc.com 跳转到本机, 请求www.bbc.com 跳转到192.168.0.35 机 ...

  9. nginx做为web容器部署静态资源以及做负载均衡反向代理实现

    需求:  此时前台开发完成打包生成静态资源文件,要做到以下方面: 使用nginx部署静态资源,同时nginx要实现端口转发,隐藏真实后台地址,同时后台需要做一个负载均衡. localhost:7001 ...

随机推荐

  1. bae使用nodejs遇到的问题---‘Fix depends failed. Please check requirements.txt.’

    今天尝试了百度开放云里面的nodejs云引擎,部署没有任何问题,修改文件后发现了发布不了,去查看发布设置发现了问题: Fix depends failed. Please check requirem ...

  2. Vue2.0项目打包后只能访问首页,其他页面路径错误找不到

    原因是你使用了vue-router的history,可以尝试去掉  // mode:"history",

  3. js二分查找树实现

    function BinaryTree() { var Node = function(key) { this.key = key; this.left = null; this.right = nu ...

  4. AIX修改时区,配置NTP服务

    AIX修改时区 smitty --> System Environments -->Change/Show Data and Time -->Change Time Zone Usi ...

  5. IBM V7000错误代码及解决

    https://www.ibm.com/support/knowledgecenter/zh/ST3FR7_7.7.1/com.ibm.storwize.v7000.771.doc/svc_error ...

  6. CentOS7系列--3.2CentOS7中配置iSCSI服务

    CentOS7配置iSCSI服务 在网络上的存贮服务为iSCSI Target,而连接到iSCSI Target服务的叫iSCSI Initiator 1. 直接配置iSCSI Target服务 1. ...

  7. js判断字符串出现的次数

    // 判断substr字符串在str中出现的次数 isIgnore是否忽略大小写! function countSubstr(str, substr, isIgnore) { var count; v ...

  8. zTree实现权限列表简单实例

    zTree的简单实例 zTree 是一个依靠jQuery 实现的多功能 "树插件".优异的性能.灵活的配置.多种功能的组合是 zTree 最大优点. zTree官网 zTreeAP ...

  9. justreq测试接口配置服务

    特性 自动缓存每一次接口请求,当测试服务器宕机时,依然可以从容开发 接口替身服务,当后台GG们还没开发好接口时,可以用json.txt等替代 独有jrs脚本,仿php,可以定制更灵活的接口替身,甚至可 ...

  10. error MSB3552: Resource file "**/*.resx" cannot be found. [/ConsoleApp1.csproj]

    问题场景: 练习在docker下操作netcore,镜像为centos7,安装完netcore sdk 2.2后,执行操作: dotnet new consoledotnet run 出现报错: /u ...