dmpayton / django-admin-honeypot

:honey_pot: A fake Django admin login screen page.
http://django-admin-honeypot.readthedocs.io/
MIT License
1.03k stars 188 forks source link

Every IP address is 172.17.0.6 #72

Closed alstr closed 4 years ago

alstr commented 4 years ago

Hello all :wave:.

I've been using a forked version of this in an app running on Google App Engine. It has a custom runtime specfied by a Dockerfile. Every login attempt at the honeypot site is said to originate from 172.17.0.6, which seems to be an infrastructure-related IP, rather than the user's IP.

The changes I made in the forked version shouldn't be a factor, so I was wondering if anyone had any thoughts?

alstr commented 4 years ago

Having done some further research, it seems like it is potentially retrieving the IP address of the load balancer. The actual IP seems to be in HTTP_X_FORWARDED_FOR rather than REMOTE_ADDR.

dmpayton commented 4 years ago

@alstr Hello! You'll need a middleware to assign the IP address. There's an example in the docs:

https://django-admin-honeypot.readthedocs.io/en/latest/manual/faq.html#why-is-the-ip-address-logged-as-127-0-0-1

alstr commented 4 years ago

Ah yes, that should sort it. Thanks!

rainer85ah commented 3 years ago

Hi Derek,

thanks for your work and time.

I was wondering if you can share a full example of this code and what I mean by that is to what exactly do we have to set in the middlewares section in settings? Does this class (class RemoteAddrMiddleware(object)) have to be in views.py file or somewhere else?

Thanks, Rainer