-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Modsecurity How to get real IP address?? #2447
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
You can use the |
@airween Thank you very much, I will try it |
This is also working for me, but if i you are using apache with mod_remoteip you should turn these off, otherwise this is empty. you can log this also via apache and logformat: |
@Dark-Schnitzel I use Nginx |
@airween { "@timestamp": "2020-11-12T14:26:06+08:00", "remote_addr": "100.97.166.33","request_time": "0.000","upstream_response_time": "","status": 200,"x_forwarded": "36.110.73.230","http_referer": "","request": "GET /status HTTP/1.1","upstream_addr": "","body_bytes_sent":637,"request_body":,"http_user_agent": "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:82.0) Gecko/20100101 Firefox/82.0" } the nginx.conf logformat is
and my rules/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf is
After adding REQUEST_HEADERS:X-Forwarded-For, my access to the website was not denied. Why? |
What's your goal? I tried with your examples (
in the
So, I think the IP address above is from CN, but you deny the request if the COUNTRY_CODE is not US. If you want to allow the request only from CN, you should replace the |
My problem now is that the configuration does not take effect. My ip address is China and only the United States is allowed in the configuration. However, my website from China is not denied and can be accessed normally, so why does my configuration not take effect? |
@airween |
What is your |
@airween |
If you only see these lines in your debug.log:
then it means that header isn't presented. You must see these lines too:
from 2nd to 4th. Btw, what is the value of the |
@airween and the maxmind website show my ip is CN,why modsecurity can't match it? |
@airween |
@airween
|
could you show me the final part of the output of the I mean:
And what did you get for this command?
Please don't insert screenshot, just copy the text and insert here. Use the "Insert code" item at the menu bar. |
@airween
and the geoLite2-Country.mdb is GeoLite2-Country.mmdb
|
Please run the |
@airween
|
MaxMind support seems to be missing:
Try to install the libmaxmind library and recompile the engine. |
@airween ok, I will install libmaxminddb and libmaxminddb-devel |
@airween
the ./configure show this
but when I run make is show some error blow
|
Your See issue #2254 (and the solution too). |
@airween Ha Ha....Finally succeeded, thank you very much! |
Our nginx server has gone through a layer of proxy, and the real user address cannot be obtained using REMOTE_ADDR,But our proxy server has a variable ($http_x_forwarded_for) to get the user's real IP address,So what is the solution for modsecurity?
The text was updated successfully, but these errors were encountered: