How to create IP blacklist in Symfony2?

前端 未结 6 1201
刺人心
刺人心 2021-02-08 17:53

Yes, I know there\'s Voter tutorial in cookbook. But I\'m looking for something slightly different. I need two different layers of blacklisting:

  1. deny certain IP to
6条回答
  •  有刺的猬
    2021-02-08 18:24

    To deny access to the entire website, you can adapt the whitelist code used to secure the dev environment. Stick something like this in app.php:

    if (in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '1.2.3.4',))) {
        header('HTTP/1.0 403 Forbidden');
        exit('You are not allowed to access this site.');
    }
    

提交回复
热议问题