-
Notifications
You must be signed in to change notification settings - Fork 43
[feature] Geolocation Blocking #730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello, I will add this with the PHP rewrite (see #731). But until then: You can mount geo databases into the NPMplus container and configure geoblocking in the advanced tab. (The nginx geoip module and the maxmind module are compiles into NPMplus) |
How i can configure in Advanced tab? What line do I have to put? Thanks |
@Revan335 Did you manage to get this up and running? I've been reading through the document but can't seem to figure out the exact config I need to put in the Advance tab to explicitly allow/block certain countries. From my understanding, it should be as simple as adding
Or alternatively:
To the advanced tab, but that makes the host go Offline. |
what is written in your log? |
The docker logs say this when I apply the Advanced Configuration
Then the host is marked "Offline" in the UI. When I remove the configuration again:
And the status goes back to Online. This is the same for every host. The container is running as root and does have rights to create/delete files:
|
I think you need to put geoip2 and map into the cusatom/http_root file |
I think that was it! Placing the following in the custom/http_top.conf file:
And then placing the if statement in the Advanced Configuration. Or even better, in the server_proxy.conf file so it applies automatically to all hosts:
Seems to have done the trick... I am now seeing HTTP 444 in the access log after starting a VPN to Germany or France:
Many thanks! |
First of all, a huge thank you for the work done around Nginx Proxy Manager Plus which I have just discovered, and of which I was using the original NPM which does not evolve too much. Did you manage to get it to work? I've looked through the docs and discussions, but I can't seem to get it to explicitly allow/block certain countries. charset utf-8; geo $allowed_ip { map $geoip2_data_country_code $allowed_country { And then placing the if statement in the Advanced Configuration like you said, Or even better, in the server_proxy.conf file so it applies automatically to all hosts: if ($allowed_country = no) { But when I do this, and I restart the docker all the sites are no longer accessible even in France, which is not the aim of the game. Could you please provide the configuration you are using or someone else can answer me so that I can implement this module which is an interesting component of NPMPlus Thanking you all in advance. |
Yup, still works for me. For reference, this is my full /opt/npm/custom_nginx/http_top.conf file:
And in my Advanced Config for any host:
So I set the "allowed country" variable to yes if we're coming in via a LAN IP address since geo-IP obviously won't work then. |
My sincere gratitude for your prompt response. I just implemented it, and now everything is working perfectly, adding yet another layer of security to this magnificent NPMPlus project. I still need to finish integrating Open-Appsec. |
Hi. It seems, that 2025-03-20 update broke this function. http_top.conf contains I have checked, that the GeoLite2-Country.mmdb exists. |
You need load the module via env, as written in the changelogs |
Thank you, Zoey. I have completely missed that information. First thing I did, was reading the changelog, but I was probably blind. |
I might be mistaken, but in the advanced configuration of the host, shouldn't we also include the following to allow Let's Encrypt to renew certificates?
|
you can test it with the built-in reachability test |
I'm following this discussion with great interest, as I'm desperately trying to get geoblocking in npmplus to work. I have a question: I've loaded all the necessary envs for geoIP in compose.yaml, but I still get the following error when loading GeoLite2-Country.mmdb in http_top.conf: "log":"nginx: [emerg] MMDB_open("/opt/npmplus/goaccess/geoip/GeoLite2-Country.mmdb") failed - Error opening the specified MaxMind DB file in /data/custom_nginx/http_top.conf:1\n" Maybe someone can give me a hint where the problem is? I did it with: |
Can you try to remove the line break after |
you mean like: if yes, still the error: |
since it is inside the container /opt/npmplus should be /data |
Alternatively, OpenAppSec supports geoblocking straight out of the box from their management UI. So if you don't want to mess around with config files too much, you can do it this way as well. (Not sure if that's per se easier, but it wasn't too hard to get openappsec up and running.) |
Hello,
how can I use Geolocation Blocking?
For example only from Germany, USA, Austria ... can I access to the Docker Container ... and Access/Connections from others are blocked.
This can increase the Security and lower Risk of Hacking ...
NPM don't have this Feature.
Have SWAG this? I don't know.
Can you add this?
Many Thanks!
Greetings
Revan335
The text was updated successfully, but these errors were encountered: