基本架构:

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/

最新文章

  1. guava 学习笔记 使用瓜娃(guava)的选择和预判断使代码变得简洁
  2. Windows 10输入法已禁用IME无法输入中文怎么办
  3. css+div盒模型研究笔记
  4. jQuery.validate的this.optional(element)作用
  5. CodeForces 696A(Lorenzo Von Matterhorn ) & CodeForces 696B(Puzzles )
  6. apache利用.htaccess实现部分页面301
  7. Excel补全日期(日期按顺序补全)
  8. python并开发编程之协程
  9. Vue-CLI和脚手架
  10. Nginx 流量和连接数限制
  11. luogu5022 [NOIp2018]旅行 (dfs)
  12. iptables转发技术
  13. Hadoop3集群搭建之——hive添加自定义函数UDF
  14. webservice复杂类型实例
  15. CTF-练习平台-Misc之 这是一张单纯的图片??
  16. schwarz( 施瓦兹)不等式证明
  17. docker实战 (1) 关于docker的安装
  18. Linux /etc/fstab文件
  19. gulp4.0 存在的错误信息 The following tasks did not complete: default,Did you forget to signal async completion?
  20. vmvare-centos7-vim

热门文章

  1. 【代码笔记】iOS-单击手势的添加
  2. CentOS 6.x 安装vnc
  3. 热血沙城-3.2移植-古月-cocos2dx源码
  4. zookeeper应用 - 监控
  5. mac下连接阿里云总是提示密码是吧,permission denied
  6. 探讨Oracle分区表
  7. Tomcat – Java.Lang.OutOfMemoryError: PermGen Space
  8. python基础_类型_dict
  9. 铁乐学python_day02-作业
  10. SQL Server错误处理