Haproxy deny access by using ACL rules to block custom IP addresses

Source: Internet
Author: User
Tags haproxy

Now there is a requirement is that in the release of the company's IP outside the network when the access to the service is denied access

Now use Haproxy's ACL rules to make restrictions

ErrorFile 403/etc/haproxy/errfile/403.http
ACL Url_bao HDR (Host)-I bao.doyoulicai.comacl kongzhong_src src 222.73.17.25 222.73.17.24http-request deny if Url_jr!kongzhong_srcuse_backend bao.doyoulicai.com if url_baobackend 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

By setting this, you can deny access to the 403 page directly when the IP address is accessed bao.doyoulicai.com other than 222.73.17.25 222.73.17.24.

And now customize the 403 page

[[Email protected]_ha_nginx errfile]# cat 403.http http/1.0 403 forbiddencache-control:no-cacheconnection: closecontent-type:text/html<! DOCTYPE html>

Haproxy deny access by using ACL rules to block custom IP addresses

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.