proxy_count and proxy_trusted_ips returning None on localhost/ngrok
Closed this issue · 1 comments
I am testing on localhost with ngrok on multiple devices and I am having problems whenever I add either proxy_count or proxy_trusted_ips to get_client_ip(). get_client_ip(request) works well on localhost on its own and gets the IP address of each device using the ngrok link. I am not using nginx or apache to test.
Example:
ip = get_client_ip(request, proxy_count=1, proxy_trusted_ips=['177.139.233.133']
print(ip)
None
It prints None each time.
I made a stackoverflow question regarding this. But I have narrowed it down to just adding either proxy_count or proxy_trusted_ips values to get_client_ip() on localhost and ngrok. You can see all the trouble it causes whenever it returns None as the ip variable.
I want to be able to test this on localhost before going to production even if it is dummy proxy_trusted_ips or proxy_count values such as 127.0.0.1 or the ngrok device ip addresses produced by my devices. I want to see that it is working otherwise it does not give me much confidence about using this library in production.
This is an extension of issue 39 which did not solve my problem and there is not enough info in the docs or on stackoverflow regarding this.
Another question I have is the proxy_trusted_ips just acts as IP addresses that you want to ignore? In other words, do not capture them / print them if their IP address is picked up and perhaps set the value as None since it gets ignored?
@9mido This package/lib is well-tested and is used by many projects in productions
. Your trust level only depends on your understanding of this package & its usage, as well as your setup and requirements. I encourage you to read the README file till
you have a good grasp
of the overall functionally.
You can also have a look at the tests, and see that all the combinations and permutations have been covered. Two good examples for your case would be:
# def test_meta_proxy_trusted_ips(self)
# def test_meta_proxy_trusted_ips_proxy_count(self)
After all the above, if you still have difficulties in fully understanding it or making it work for you use case, then it may be safer that you don't use it, since a misconfigured setup not only negates ipware's
value proposition, but it may indeed cripple your system.
If others in the community have a knowledge of similar setup as yours, I encourage them to hop on the stackoverflow link above and help out.