nginx-proxy-manager icon indicating copy to clipboard operation
nginx-proxy-manager copied to clipboard

Add GeoIP module

Open teodorch85 opened this issue 6 years ago • 98 comments

Hi! As I am noob with nginx is it possible to enable the GeoIP module so we can limit access also by location? https://docs.nginx.com/nginx/admin-guide/security-controls/controlling-access-by-geoip/

Thank you!

teodorch85 avatar Jan 08 '19 17:01 teodorch85

Sounds doable. Makes sense to include with improvements in #38 as well.

jc21 avatar Jan 08 '19 23:01 jc21

the geoip module is active by default so no worry. its just a bit of path mapping and edit config files :P

the main problem of geoip module is using legacy geoip databases that are deprecated. from https://dev.maxmind.com/geoip/legacy/downloadable/ to https://dev.maxmind.com/geoip/geoip2/geolite2/ wich is using maxmind databases

but the geoip module from nginx is using teh legacy databases. so i dont know if its an issue from nginx itselfs or from npm. it sounds nice to block countries etc but i thing nginx need to fix it first before this feature can addet by devs to the container or am i wrong ? i wrote more to -> #78

wuast94 avatar Feb 21 '19 11:02 wuast94

Yep I've found the legacy databases are not longer supplied anymore so everyone has to convert to geo2.

Seems it's trivial to add the new module: https://docs.nginx.com/nginx/admin-guide/dynamic-modules/geoip2/

Also the geolite databases need to be baked in to the docker image.

jc21 avatar Feb 25 '19 00:02 jc21

I think it should be better to make this possible over mounting the nginx dir to host system. So everyone can edit this as wanted (use other modules or databases)

And I think the geo2 module should be addet by nginx docker Mainter. Many modules are installed by defoult: https://github.com/nginxinc/docker-nginx/blob/master/stable/alpine/Dockerfile

wuast94 avatar Feb 25 '19 17:02 wuast94

You can already do that if you want to. In any docker image there is no restriction in what you're mounting and where. Even though I bake in config or files you're always able to override them.

jc21 avatar Feb 25 '19 22:02 jc21

I would really love this feature. :)

corvy avatar Apr 24 '20 13:04 corvy

This would be awesome because in order to use this

Currently nginx fails with this error when I add the custom log format:

2020/07/09 16:36:21 [emerg] 3022#3022: unknown "geoip2_data_city_name" variable

I need the geoIP information to send to InfluxDB custom format:

log_format custom '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" $host "$http_user_agent" "$request_time" "$upstream_connect_time" "$geoip2_data_city_name" "$geoip2_data_country_code"';

ghallford avatar Jul 09 '20 20:07 ghallford

Looking forward to this!

joggs avatar Aug 17 '20 19:08 joggs

Still missing and everything I'm waiting for! 👍

brokoler avatar Nov 16 '20 20:11 brokoler

That sounds great to me

risiman avatar Jan 31 '21 11:01 risiman

Likewise this will help massively in reducing attempted logons and bruteforcing on my network. Watching closely.

andyshutak avatar Feb 25 '21 18:02 andyshutak

Hi guys, this would be great! I was trying to get the geoip module or to at least implement a kind of monitoring possibility for the ngxin proxy manager with telegraf and grafana. But my limited docker knowledge is just not enough. I would appreciate if this feature would be available out of the box :) Stay healthy!

Br3b avatar Mar 02 '21 17:03 Br3b

This would be great!

rh535 avatar Mar 31 '21 23:03 rh535

@jc21 any update? I would be happy to help develop on this if y'all need an extra hand in order to get it included.

danner26 avatar Apr 15 '21 14:04 danner26

+1

mgutt avatar Apr 19 '21 05:04 mgutt

Is there any way, to do this without it implemented? If I can set it up manually I may be able to make an PR out of it.

phrogg avatar Apr 26 '21 16:04 phrogg

Checking in to see if how this is going. @jc21 is there any update please. It would be great to have this implemented please and thank you!

mouseron avatar Jul 20 '21 08:07 mouseron

See #1202

jc21 avatar Jul 20 '21 11:07 jc21

See #1202

Thanks and it's great to see there will be a V3! I wasn't aware.

It's not clear not me whether GeoIP2 will be part of this new version though... The closest statement I could find was "UI Configurable IP ranges for real_ip determination"

Will GeoIP2 be incorporated?

Thanks again!

mouseron avatar Jul 20 '21 23:07 mouseron

@mouseron Take a look at https://github.com/sherpya/geolite2legacy and https://www.miyuru.lk/geoiplegacy

Pacerino avatar Sep 12 '21 01:09 Pacerino

the geoip module is active by default so no worry. its just a bit of path mapping and edit config files :P

the main problem of geoip module is using legacy geoip databases that are deprecated. from https://dev.maxmind.com/geoip/legacy/downloadable/ to https://dev.maxmind.com/geoip/geoip2/geolite2/ wich is using maxmind databases

but the geoip module from nginx is using teh legacy databases. so i dont know if its an issue from nginx itselfs or from npm. it sounds nice to block countries etc but i thing nginx need to fix it first before this feature can addet by devs to the container or am i wrong ? i wrote more to -> #78

Hey @wuast94 i was wondering how the geoip module is active by default when the openresty doesnt get compiled with the flag to enable the geoip module? It would be nice if you could explain in detail how you managed it. The anweres you've made arent detailed.

Pacerino avatar Sep 12 '21 19:09 Pacerino

Should anyone want to look at adding the module:

  • https://github.com/NginxProxyManager/docker-nginx-full/blob/master/docker/Dockerfile
  • https://github.com/NginxProxyManager/docker-nginx-full/blob/master/scripts/build-openresty

jc21 avatar Sep 13 '21 00:09 jc21

Here some useful material to compile geoip2 in openresty https://www.electrosoftcloud.com/en/compile-geoip2-in-openresty-and-how-to-use-it/

ghost avatar Oct 28 '21 17:10 ghost

Did this get progressed any? Or is it waiting for someone to pick it up?

OuticNZ avatar Oct 31 '21 04:10 OuticNZ

No, I don't think there is any progress, and I don't think there will come an official integration in v2 of npm, unless someone wants to get working on it and creates a PR.

chaptergy avatar Oct 31 '21 15:10 chaptergy

I've actually made my own custom version of it with geoIP in order to use it with loki and grafana. https://github.com/Pacerino/docker-nginx-full https://github.com/Pacerino/nginx-proxy-manager

The only think is that i've ported the CI to Drone. There is an error appearing if creating the container about missing deps. I've temporary fixed it by installing libgeoip1_1.6 manually with DPKG

wget http://ftp.de.debian.org/debian/pool/main/g/geoip/libgeoip1_1.6.12-7_amd64.deb
dpkg -i libgeoip1_1.6.12-7_amd64.deb

After a reboot of the container everything works.

This is a quick and dirty implementation of it and not the latest release the main repo. The Frontend is missing the Logo but everything works. I should merge into the latest release and trying to get rid of the missing dep and the logo.

Pacerino avatar Oct 31 '21 16:10 Pacerino

Does anyone care about a geoip2 implementation? It would be a real pity if you have to give up the security of geoip2 for the really great and convenient variant of NPM.

firebowl avatar Jan 01 '22 18:01 firebowl

I personally do.

On Sat, Jan 1, 2022, 13:58 firebowl @.***> wrote:

Does anyone care about a geoip2 implementation? It would be a real pity if you have to give up the security of geoip2 for the really great and convenient variant of NPM.

— Reply to this email directly, view it on GitHub https://github.com/jc21/nginx-proxy-manager/issues/46#issuecomment-1003601029, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6JNIY4BQSLDMNGMXLQ2YTUT5FEFANCNFSM4GOX4ASA . You are receiving this because you commented.Message ID: @.***>

danner26 avatar Jan 01 '22 19:01 danner26

I do as well!

⁣-- Geoff​

On Jan. 1, 2022, 2:03 p.m., at 2:03 p.m., Daniel Anner @.***> wrote:

I personally do.

On Sat, Jan 1, 2022, 13:58 firebowl @.***> wrote:

Does anyone care about a geoip2 implementation? It would be a real pity if you have to give up the security of geoip2 for the really great and convenient variant of NPM.

— Reply to this email directly, view it on GitHub

https://github.com/jc21/nginx-proxy-manager/issues/46#issuecomment-1003601029,

or unsubscribe

https://github.com/notifications/unsubscribe-auth/AB6JNIY4BQSLDMNGMXLQ2YTUT5FEFANCNFSM4GOX4ASA

. You are receiving this because you commented.Message ID: @.***>

-- Reply to this email directly or view it on GitHub: https://github.com/jc21/nginx-proxy-manager/issues/46#issuecomment-1003601979 You are receiving this because you commented.

Message ID: @.***>

ghallford avatar Jan 01 '22 19:01 ghallford

Hi, this would be great for me too !

Pl1997 avatar Jan 17 '22 09:01 Pl1997