Hi
I'm in the process of migrating a Django site from Webfaction. All's going fine but I have some questions related to uwsgi (as I'm coming from an Apache/mod_wsgi setup) which I'm hoping someone might be able to help with please?
I'd like to update my uwsgi.ini to block access to the application based on IP etc. The uwsgi.log for the app shows the remote address as 127.0.0.1 (as I'm assuming there's a proxy) for all requests. Let's say I want to block 192.168.1.23 (I realise it's a private IP but I'm just using it as an example so I don't quote someone's genuine IP in this question) then the below won't block access:
route-remote-addr = ^192\.168\.1\.23$ break:403 Forbidden
Through a process of reading the docs here: https://uwsgi-docs.readthedocs.io/en/latest/InternalRouting.html and trial and error I've found that configuring the logging in uwsgi to use log-x-forwarded-for
passes through the genuine IP address to the uwsgi.log and also allows to above line to block the IP. So adding this to uwsgi.ini
this works and would block access from that IP (if it were genuine):
log-x-forwarded-for = true
route-remote-addr = ^192\.168\.1\.23$ break:403 Forbidden
Is this the correct way of doing this? It seems a bit odd to change the logging format to make this work but maybe it's the correct thing to do?
Also, the IP addresses are given as a regex and I can make the regex more permissive to block a range but does anyone know if you can use CIDR notation with route-remote-addr
and, if so, how?
The final questions I have are about IPv6. Can I also block an IPv6 address using route-remote-addr
as all the examples seem to be for a regex match of an IPv4 address?
Also I noticed that AAAA records are not created as part of the Opalstack DNS records so should I be adding this record myself?
Many thanks in advance
Kieren