现在有一个需求就是在发版的时候希望除公司IP外的外网访问服务的时候都是拒绝访问的

现在利用haproxy 的acl规则作出限制

errorfile       403 /etc/haproxy/errfile/403.http
acl url_bao hdr(Host) -i bao.doyoulicai.com
acl kongzhong_src src 222.73.17.25 222.73.17.24
http-request deny if url_jr !kongzhong_src
use_backend bao.doyoulicai.com if url_bao
backend bao.doyoulicai.com
balance roundrobin
option httpchk GET /test HTTP/1.0
server 10.9.6.18:6011 10.9.6.18:6011 check inter 60000 rise 2 fall 5 weight 10

按照这样设置的话就可以实现当除222.73.17.25 222.73.17.24以外的其他IP地址访问bao.doyoulicai.com的时候都直接拒绝访问403页面

然后现在自定义一下403页面

[root@test_ha_nginx errfile]# cat 403.http
HTTP/1.0 403 Forbidden
Cache-Control: no-cache
Connection: close
Content-Type: text/html <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<!--<link rel="stylesheet" href="/static/css/new_error.css">-->
<style>
*{
margin:0;
padding:0;
}
body{
background-color: #f3f3f3;
}
.content{
width:380px;
height:400px;
position:absolute;
top:50%;
left:50%;
transform: translate(-50%,-50%);
}
.content .main{
z-index: 5;
position:relative;
}
.content .main .post{
position:absolute;
top:100px;
left:40px;
width:11px;
height:99px;
border:3px solid #959595;
border-radius: 5px;
border-bottom: none;
}
.content .main .post2{
left:112px;
}
.content .main .tops{
position:absolute;
top:108px;
left:16px;
width:134px;
height:25px;
border:3px solid #959595;
border-radius: 5px;
z-index: 3;
background-color: #FFFFFF;
}
.content .main .tops i{
display: block;
width:37px;
height:2px;
position:absolute;
top:11px;
left:4px;
background-color: #959595;
transform: rotate(-43deg);
}
.content .main .tops i.i1{
left:33px;
}
.content .main .tops i.i2{
left:62px;
}
.content .main .tops i.i3{
left:92px;
}
.content .main .foot{
position:absolute;
top:199px;
left:33px;
width:24px;
height:7px;
border:3px solid #959595;
border-radius: 5px;
background-color: #f3f3f3;
}
.content .main .foot2{
left:105px;
} /*STOP*/
.content .stops{
z-index: 5;
position:relative;
}
.content .stops .big{
position:absolute;
top:-30px;
left:163px;
width:112px;
height:112px;
border:3px solid #959595;
border-radius: 50%;
background-color:#fff;
}
.content .stops .big .min{
position:absolute;
top:8px;
left:8px;
width:90px;
height:90px;
border:3px solid #959595;
border-radius: 50%;
font:bold 24px/90px "微软雅黑";
text-align: center;
color:#666666;
background-color:#fff;
}
.content .stops .middle{
position:absolute;
top:87px;
left:210px;
width:15px;
height:111px;
border:3px solid #959595;
border-bottom: none;
border-top: none;
}
.content .stops .foots{
position:absolute;
top:198px;
left:205px;
width:24px;
height:7px;
border:3px solid #959595;
border-radius: 4px;
}
.content h2{
z-index: 3;
width:600px;
position:absolute;
top:230px;
left:-41px;
font:30px/80px "微软雅黑";
color:#666;
} /*帽子*/
.content .cap{
position:relative; }
.content .cap .left{
z-index: 3;
position:absolute;
top:181px;
left:126px;
width:61px;
height:3px;
background-color: #959595;
transform: rotate(-71deg);
}
.content .cap .right{
z-index: 3;
position:absolute;
top:181px;
left:145px;
width:61px;
height:3px;
background-color: #959595;
transform: rotate(71deg);
}
.content .cap .round{
z-index: 3;
position:absolute;
top:116px;
left:135px;
width:62px;
height:62px;
border:2px solid #959595;
border-radius: 50%;
border-top: none;
border-right:none;
border-left: none;
}
.content .cap .round2{
z-index: 3;
width:162px;
height:162px;
top:31px;
left:86px;
}
.content .cap .round3{
z-index: 2;
width:200px;
height:200px;
top:12px;
left:66px;
background-color:#f3f3f3;
}
.content .cap .just{
position:absolute;
top:-15px;
left:150px;
width:200px;
height:200px;
background-color: #f3f3f3;
z-index: 4;
transform: rotate(71deg);
}
.content .cap .just2{
top:-15px;
left:-17px;
transform: rotate(-71deg);
}
.content .cap .foots{
z-index: 1;
position:absolute;
top:199px;
left:144px;
width:37px;
height:37px;
border-radius: 5px;
/*transform: skew(30deg,30deg);*/
border:3px solid #959595;
transform: rotate(38deg) skew(-34deg,-13deg);
}
</style>
</head>
<body>
<div class="content">
<div class="main">
<!--立柱子两个-->
<div class="post"></div>
<div class="post post2"></div>
<!--横柱子-->
<div class="tops">
<i></i>
<i class="i1"></i>
<i class="i2"></i>
<i class="i3"></i>
</div>
<!--脚底-->
<div class="foot"></div>
<div class="foot foot2"></div>
</div>
<!--帽子-->
<div class="cap">
<!--<div class="skews"></div>-->
<!--左边横线-->
<div class="left"></div>
<!--右边横线-->
<div class="right"></div>
<!--三个圆-->
<div class="round"></div>
<div class="round round2"></div>
<div class="round round3"></div>
<!--两个正方形做遮盖-->
<div class="just"></div>
<div class="just just2"></div>
<!--帽子的底部-->
<div class="foots"></div>
</div>
<!--stop-->
<div class="stops">
<div class="big">
<div class="min">
STOP
</div>
</div>
<div class="middle"></div>
<div class="foots"></div>
</div> <!--文字-->
<h2>哎呀!服务器停机维护中...</h2>
</div>
</body>
</html>

haproxy利用ACL规则封禁自定义IP地址拒绝访问的更多相关文章

  1. 利用 ipset 封禁大量 IP

    使用 iptables 封 IP,是一种比较简单的应对网络攻击的方式,也算是比较常见.有时候可能会封禁成千上万个 IP,如果添加成千上万条规则,在一台注重性能的服务器或者本身性能就很差的设备上,这就是 ...

  2. httpd进程数统计,IP封禁,IP连接数量情况查看

    ps -ef|grep httpd|wc -l 统计httpd进程数,连个请求会启动一个进程,使用于Apache服务器. 查看Apache的并发请求数及其TCP连接状态:netstat -n | aw ...

  3. 教你怎样写自定义IP地址算法

    通过IP地址可以看到算法规律,写成自定义IP地址,也可以把IP地址转为自定格式的IP地址.也可以用于加密一些明文数字.起始次方可自定义(以1次方和0次方为例) a.以下写正反算法(以1次方为最小单位) ...

  4. Linux tomcat设置ip地址直接访问,tomcat设置ip地址直接访问,tomcat绑定ip地址

    Linux tomcat设置ip地址直接访问,tomcat设置ip地址直接访问,tomcat绑定ip地址 >>>>>>>>>>>> ...

  5. mysql数据库可以远程连接或者说用IP地址可以访问

    mysql数据库可以远程连接或者说用IP地址可以访问 一般情况不建议直接修改root的权限, 先看下,自己mysql数据库的用户级权限 mysql -u root -p----->用root登陆 ...

  6. java struts2入门学习实例--将客户端IP地址和访问方式输出到浏览器

    实例1:实现客户端IP地址和访问方式输出到浏览器. IpAction.java package com.amos.web.action; import javax.servlet.http.HttpS ...

  7. HAProxy(二):HAProxy的ACL规则实现智能负载均衡详解与示例

    一.HAProxy的ACL的功能 ACL(Access Control List)访问控制列表,HAProxy中的ACL的匹配条件和控制条件有许多种,功能很强大,可以通过源地址.源端口.目标地址.目标 ...

  8. haproxy 常用acl规则与会话保持

    一.常用的acl规则 haproxy的ACL用于实现基于请求报文的首部.响应报文的内容或其它的环境状态信息来做出转发决策,这大大增强了其配置弹性.其配置法则通常分为两 步,首先去定义ACL,即定义一个 ...

  9. CentOS7 下使用 Firewall防火墙系统封禁允许IP和端口的访问 端口转发 IP转发方法

    CENTOS7的防火墙系统默认已经从iptable改成了firewall,使用方法也有所不同,下面是详细介绍 一.管理端口 列出 dmz 级别的被允许的进入端口 # firewall-cmd --zo ...

随机推荐

  1. getJson

    $.getJSON("<%=basePath%>delivery/auditing.do",{Phones:Phones,currPage:currPage,timst ...

  2. Linux下安装Redis

    1. 下载最新版本的Redis源代码: 命令:wget http://download.redis.io/redis-stable.tar.gz 2. 解压并编译 命令:tar xzf redis-s ...

  3. springboot 学习资源推荐

    springboot 是什么?对于构建生产就绪的Spring应用程序有一个看法. Spring Boot优先于配置的惯例,旨在让您尽快启动和运行.(这是springboot的官方介绍) 我们为什么要学 ...

  4. Golang接口(interface)三个特性(译文)

    The Laws of Reflection 原文地址 第一次翻译文章,请各路人士多多指教! 类型和接口 因为映射建设在类型的基础之上,首先我们对类型进行全新的介绍. go是一个静态性语言,每个变量都 ...

  5. Java三大框架之——Hibernate

    什么是Hibernate? Hibernate是基于ORM(O:对象,R:关系,M:映射)映射的持久层框架,是一个封装JDBC的轻量级框架,主要实现了对数据库的CUPD操作. 注:CRUD是指在做计算 ...

  6. EF 添加方式比较

    using System; using System.Collections.Generic; using DBAccess.Models; using EntityFramework.BulkIns ...

  7. Atitit.软件架构高扩展性and兼容性原理与概论实践attilax总结

    Atitit.软件架构高扩展性and兼容性原理与概论实践attilax总结 1. 什么是可扩展的应用程序?1 2. 松耦合(ioc)2 3. 接口的思考 2 4. 单一用途&模块化,小粒度化2 ...

  8. 《简单的自定义DropDatePicker》-- UIPopoverController 和 代理 以及 Block 实现。

    最近做项目为了方便项目使用,自定义的空间 写的比较粗糙.欢迎大家批评指正.以上为在项目中的实际应用 // DropDownDatePicker.h // DropDownDatePickerDemo ...

  9. Android中使用ListView实现分页刷新(线程休眠模拟)

    当要显示的数据过多时,为了更好的提升用户感知,在很多APP中都会使用分页刷新显示,比如浏览新闻,向下滑动到当前ListView的最后一条信息(item)时,会提示刷新加载,然后加载更新后的内容.此过程 ...

  10. jQuery Validate 表单验证 — 用户注册简单应用

    相信很多coder在表单验证这块都是自己写验证规则的,今天我们用jQuery Validate这款前端验证利器来写一个简单的应用. 可以先把我写的这个小demo运行试下,先睹为快.猛戳链接--> ...