Closed jdabtieu closed 1 year ago
Note that the PYTHONANYWHERE_SITE
envvar is only set on PythonAnywhere.
I think honestly the way to deal with this is to create a middleware to rewrite request.remote_addr to request.header["X-Real-IP"] if the user sets some boolean in the settings
Describe the bug
Because of their load balancer, request.remote_addr returns the address of the load balancer
Same happens for Nginx forwarding traffic to Docker
It should return the address of the remote user, but instead, they use
request.headers['X-Real-IP']
instead.Possible Solution
Add a check for Pythonanywhere, and overwrite request.remote_addr with the real IPOverwrite request.remote_addr withrequest.headers['X-Real-IP']
if the app is run under a proxyworks on PythonAnywhere and for Nginx, if it's set (vulnerability if nginx is misconfigured, perhaps we should add something in the docs/settings about this)