Hi, here you have some examples: Web server level
Here there is examples about how to deny an IP and network ranges in nginx, if you can modify the nginx.conf file then is easy. https://www.cyberciti.biz/faq/linux-unix-nginx-access-control-howto/ At OS level. If you have control of IP tables you can do it there also. This is how to block an entire subnet: # iptables -A INPUT -s 192.168.100.0/24 -j DROP Application level: In your model (db.py) add the following at the beginning: Example with multiples ip ranges if IS_IPV4(minip=('192.168.20.19', '192.168.30.100'),maxip=('192.168.20.19', '192.168.30.199'))(request['env']['REMOTE_ADDR'])[1] == None: raise HTTP(403) -- Cheers. Chris. > On martes, oct. 27, 2020 at 2:45 p. m., Eliezer (Vlad) Tseytkin > <westgate6...@gmail.com (mailto:westgate6...@gmail.com)> wrote: > I see... Could you please give me a hint on where to find how to accomplish > this in nginx? (I use PythonAnywhere) > On Tue, Oct 27, 2020 at 1:15 AM valq...@gmail.com (mailto:valq...@gmail.com) > <valq7...@gmail.com (mailto:valq7...@gmail.com)> wrote: > > It is better to do this at front server like nginx, Apache or even at > > os-level. In web2py, models files are processed for each request, so you > > can just raise HTTP at db.py > > > > вторник, 27 октября 2020 г. в 04:52:57 UTC+3, Vlad: > > > I've discovered that my site is constantly bothered by weird locations - > > > not that there is anything intrinsically wrong with those countries, but > > > those locations have nothing to do with actual customers. I want to > > > reject the requests from those locations altogether. > > > > > > I can reject any specific page in controller code, but how do I reject > > > ANY request altogether, without coding it into multiple places? -- > > Resources: > > - http://web2py.com > > - http://web2py.com/book (Documentation) > > - http://github.com/web2py/web2py (Source code) > > - https://code.google.com/p/web2py/issues/list (Report Issues) > > --- > > You received this message because you are subscribed to a topic in the > > Google Groups "web2py-users" group. > > To unsubscribe from this topic, visit > > https://groups.google.com/d/topic/web2py/af2Ct41wEE0/unsubscribe. > > To unsubscribe from this group and all its topics, send an email to > > web2py+unsubscr...@googlegroups.com > > (mailto:web2py+unsubscr...@googlegroups.com). > > To view this discussion on the web visit > > https://groups.google.com/d/msgid/web2py/36ef2c26-b63f-48f1-b032-51f4774171c6n%40googlegroups.com > > > > (https://groups.google.com/d/msgid/web2py/36ef2c26-b63f-48f1-b032-51f4774171c6n%40googlegroups.com?utm_medium=email&utm_source=footer). > -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to web2py+unsubscr...@googlegroups.com > (mailto:web2py+unsubscr...@googlegroups.com). > To view this discussion on the web visit > https://groups.google.com/d/msgid/web2py/CABZ%2BKCCmiak3RNNqhWxDmy0YCuutZS5z3FU9QbQLUnDCcBO91w%40mail.gmail.com > > (https://groups.google.com/d/msgid/web2py/CABZ%2BKCCmiak3RNNqhWxDmy0YCuutZS5z3FU9QbQLUnDCcBO91w%40mail.gmail.com?utm_medium=email&utm_source=footer). -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/7d747bbc-1bc2-4161-81a3-684c39da7886%40Canary.
signature.asc
Description: PGP signature