Hello everyone.
I have a small problem that unfortunately I couldn’t solve on my own.
I created my django project. This is not a very complicated project.
I installed “django-axes” and configured it following the appropriate documentation.
The problem is that once deployed on pythonanywhere.com, django-axes always detects the same IP address regardless of the real IP that logs in.
I tried to document myself and it seems that the problem is due to pythonanywhere balanced proxy.
Therefore, carefully reviewing the django-axes and pythonanywhere documentation, I tried to make the following changes:
settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app1',
'app2',
'django_filters',
'import_export',
'djmoney',
'crispy_forms',
'crispy_bootstrap5',
'axes',
]
MIDDLEWARE = [
#the last middleware inserted:
'axes.middleware.AxesMiddleware',
]
AUTHENTICATION_BACKENDS = [
# AxesStandaloneBackend should be the first backend in the AUTHENTICATION_BACKENDS list.
'axes.backends.AxesStandaloneBackend',
# Django ModelBackend is the default authentication backend.
'django.contrib.auth.backends.ModelBackend',
]
# refer to the Django request and response objects documentation
AXES_IPWARE_PROXY_COUNT = 1
AXES_IPWARE_META_PRECEDENCE_ORDER = [
'HTTP_X_REAL_IP',
'HTTP_X_FORWARDED_FOR',
'REMOTE_ADDR',
]
I set ‘HTTP_X_REAL_IP’ first because it is specified in the pythonanywhere instructions:
Despite this, even if I try to change the order of the contents of “AXES_IPWARE_META_PRECEDENCE_ORDER”
or I remove the setting “AXES_IPWARE_PROXY_COUNT = 1”
the IP address reported by django-axes always remains the same.
What am I doing wrong?
Do I still need to configure anything?
Thank you all so much for your constant availability.
I accept every little advice and help that you are kindly able to give me.
Sorry for my bad English.
Happy Coding!