kubernetes / ingress-nginx

Ingress-NGINX Controller for Kubernetes
https://kubernetes.github.io/ingress-nginx/
Apache License 2.0
17.26k stars 8.2k forks source link

Having both libmaxminddb-dev and geoip-dev in Ingress-Nginx makes geo database not work with ModSecurity #11738

Closed K-izme closed 1 month ago

K-izme commented 1 month ago

What happened:

I used ModSecurity with GeoLite2-City.mmdb in ingress-nginx to restrict access from some country. In mod security debug log, it show a message: "Database is not open. Use: SecGeoLookupDb directive." And in ingress-nginx log, there is a line: The GeoIP2 feature is enabled but the databases are missing. Disabling I used Maxmind Database. It's all fine when I tested on my local machine but when I bring it on my server to test it again, it won't work any more. There's not much difference between my test on local machine and on my server. Then I tried to use the geoip module with GeoLiteCity.dat but still got this issue. I'm sure that it's exist in the right folder.

What you expected to happen:

The database is open and mod security can read it. I think this problem was mentioned in [https://github.com/owasp-modsecurity/ModSecurity/issues/2041](This issue) and #6450 . I tried to rollout restart deployment but there's no use.

NGINX Ingress controller version :

Helm chart 4.7.5, ingress-nginx-controller version 1.8.5

Kubernetes version:

v1.24.6

Environment:

How to reproduce this issue: Create a pv and pvc and mount that to ingress-nginx-controller /etc/nginx/geoipmmdb, download Maxmind Lite City database. Apply the annotation and then restart the deployment of ingress-nginx.

image

k8s-ci-robot commented 1 month ago

This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
longwuyuan commented 1 month ago

/remove-kind bug /kind support

I have tested recently and the download option for the db works. So there is no problem with the controller I know. https://github.com/kubernetes/ingress-nginx/issues/11320

The reason for your config of a mounted volume not working could be one of many factors. Unless you can write a detailed step by step procedure and not a simple overview of the reproduce process, I think it will be difficult to understand the root-cause

longwuyuan commented 1 month ago

/retitle maxmind database mount not working

longwuyuan commented 1 month ago

The automatic download option is keeping the db file here ;

/etc/nginx $ find / -name "GeoLite2*" 2>/dev/null
/etc/ingress-controller/geoip/GeoLite2-ASN.mmdb
/etc/ingress-controller/geoip/GeoLite2-City.mmdb
/etc/nginx $ 

so you may want to check the docs too https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#use-geoip2

K-izme commented 1 month ago

/remove-kind bug

/kind support

I have tested recently and the download option for the db works. So there is no problem with the controller I know. https://github.com/kubernetes/ingress-nginx/issues/11320

The reason for your config of a mounted volume not working could be one of many factors. Unless you can write a detailed step by step procedure and not a simple overview of the reproduce process, I think it will be difficult to understand the root-cause

I found out that my backend of ingress-nginx reload twice due to some change when i rollout restart deployment. That's why i have this problem. The problem about reload cause the db not work here issue

K-izme commented 1 month ago

When I update to ingress-nginx-controller v1.10.0, it won't have both libmaxminddb-dev and geoip-dev. Then this error doesn't happen anymore. Now I can restrict ip from another country. A comment from @victorhora Here image