Skip to content
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

Proxy NGINX is not sending REMOTE_ADDR - not working on production. #251

Closed
hvitis opened this issue Jun 28, 2022 · 3 comments
Closed

Proxy NGINX is not sending REMOTE_ADDR - not working on production. #251

hvitis opened this issue Jun 28, 2022 · 3 comments

Comments

@hvitis
Copy link

hvitis commented Jun 28, 2022

I have tried all the possible combinations of adding site (as URL in settings and as domain in Site.objects.get_current().domain)

It is working fine on localhost but after deploying (gunicorn, nginx) it is not logging anything.

Any ideas what I might add / open ?

Thanks

@hvitis
Copy link
Author

hvitis commented Jun 28, 2022

Dummy me, didn´t check the logs:

WARNING:request.security.middleware:Bad request: {'ip': ['Este campo no puede estar vacío.']}

I tracked it to be the ip model that is not being filled by IP address.
The function causing the trouble is:

from_http_request()

self.ip = request.META.get('REMOTE_ADDR', '')

 def save(self, *args, **kwargs):
        if not request_settings.LOG_IP:
            self.ip = request_settings.IP_DUMMY

Even when I did set up the LOG_IP and IP_DUMMY I was triggered an error.
Of course I went to NGINX and tweaked some thing but also learned that the solution here is not 100% nice.

I will make some changed and wiil push PR.

Thanks

@hvitis hvitis changed the title Any ideas why it might be not working on production? Proxy NGINX is not sending REMOTE_ADDR - not working on production. Jun 28, 2022
@hvitis
Copy link
Author

hvitis commented Jun 28, 2022

Found a fix here:
#57

@hvitis
Copy link
Author

hvitis commented Jun 28, 2022

Opened my PR
#252

@hvitis hvitis closed this as completed Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant