Heather and Jon Turgeon
2017-07-11 17:09:38 UTC
Yes, this call was done on a server running on a Ubuntu VPS that is public facing. One reason I did not use the client side HTML5 geo location was the user has to agree to allow it. My site is a sailing site for navigation so they usually do anyway to get the most out of the site but I have had some users shy away from it. Anyway I ended up using a web service call (freegeoip) from the client side using jQuery. All I care about is the country (I want to highlight the global use of the site) and this seems to do it. Anyway, thanks all for the help, I will probably try the X-Forward-For in a webhook that I have as I do not have control over the UI. Thanks.
Jon
________________________________
From: stripes-users-***@lists.sourceforge.net <stripes-users-***@lists.sourceforge.net>
Sent: Monday, July 10, 2017 8:07 AM
To: stripes-***@lists.sourceforge.net
Subject: Stripes-users Digest, Vol 124, Issue 2
Send Stripes-users mailing list submissions to
stripes-***@lists.sourceforge.net
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.sourceforge.net/lists/listinfo/stripes-users
or, via email, send a message with subject or body 'help' to
stripes-users-***@lists.sourceforge.net
You can reach the person managing the list at
stripes-users-***@lists.sourceforge.net
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Stripes-users digest..."
Today's Topics:
1. Re: Getting users location (Rick Grashel)
----------------------------------------------------------------------
Message: 1
Date: Sun, 9 Jul 2017 16:36:14 -0500
From: Rick Grashel <***@gmail.com>
To: Stripes Users List <stripes-***@lists.sourceforge.net>
Subject: Re: [Stripes-users] Getting users location
Message-ID:
<CADoNxeNBOBm0f4C1KAGgwFOn5X9En+X=0Uciid+M-***@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
That IPv6 address is localhost. So you maybe have been trying to access
the site from the server itself. I don't know of any situation (outside of
IP spoofing) where localhost would be returned from that call. Did you
actually try to hit your web service/page from someplace on the public
internet?
Regardless, getRemoteAddr() is not fully dependable anyways. If it were
me, I would first check for the presence of an "X-Forwarded-For" header and
use that. If that is null (or if it is not a valid IP address -- or a
listing of IP addresses/ranges), then fall back to getRemoteAddr(). You
could even check one against the other.
If you are fronting your own application server with a load balancer or
firewall, then you will undoubtedly need to use the "X-Forwarded-For"
header. Otherwise, the getRemoteAddr() will return the IP address of your
own firewall.
-- Rick
On Sun, Jul 9, 2017 at 12:18 PM, Heather and Jon Turgeon <
An HTML attachment was scrubbed...
------------------------------
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
------------------------------
Subject: Digest Footer
_______________________________________________
Stripes-users mailing list
Stripes-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users
------------------------------
End of Stripes-users Digest, Vol 124, Issue 2
*********************************************
Jon
________________________________
From: stripes-users-***@lists.sourceforge.net <stripes-users-***@lists.sourceforge.net>
Sent: Monday, July 10, 2017 8:07 AM
To: stripes-***@lists.sourceforge.net
Subject: Stripes-users Digest, Vol 124, Issue 2
Send Stripes-users mailing list submissions to
stripes-***@lists.sourceforge.net
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.sourceforge.net/lists/listinfo/stripes-users
or, via email, send a message with subject or body 'help' to
stripes-users-***@lists.sourceforge.net
You can reach the person managing the list at
stripes-users-***@lists.sourceforge.net
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Stripes-users digest..."
Today's Topics:
1. Re: Getting users location (Rick Grashel)
----------------------------------------------------------------------
Message: 1
Date: Sun, 9 Jul 2017 16:36:14 -0500
From: Rick Grashel <***@gmail.com>
To: Stripes Users List <stripes-***@lists.sourceforge.net>
Subject: Re: [Stripes-users] Getting users location
Message-ID:
<CADoNxeNBOBm0f4C1KAGgwFOn5X9En+X=0Uciid+M-***@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
That IPv6 address is localhost. So you maybe have been trying to access
the site from the server itself. I don't know of any situation (outside of
IP spoofing) where localhost would be returned from that call. Did you
actually try to hit your web service/page from someplace on the public
internet?
Regardless, getRemoteAddr() is not fully dependable anyways. If it were
me, I would first check for the presence of an "X-Forwarded-For" header and
use that. If that is null (or if it is not a valid IP address -- or a
listing of IP addresses/ranges), then fall back to getRemoteAddr(). You
could even check one against the other.
If you are fronting your own application server with a load balancer or
firewall, then you will undoubtedly need to use the "X-Forwarded-For"
header. Otherwise, the getRemoteAddr() will return the IP address of your
own firewall.
-- Rick
On Sun, Jul 9, 2017 at 12:18 PM, Heather and Jon Turgeon <
Hi all, I am trying to get the users general location server side (the
country). I have tried getContext().getRequest().getRemoteAddr(); bu that
just returns 0:0:0:0:0:0:0:1 (was going to use a web service to get the
country from the IP address). Has anyone been able to do this and if so
can you point me in the right direction? Thanks again.
Jon
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Stripes-users mailing list
https://lists.sourceforge.net/lists/listinfo/stripes-users
-------------- next part --------------country). I have tried getContext().getRequest().getRemoteAddr(); bu that
just returns 0:0:0:0:0:0:0:1 (was going to use a web service to get the
country from the IP address). Has anyone been able to do this and if so
can you point me in the right direction? Thanks again.
Jon
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Stripes-users mailing list
https://lists.sourceforge.net/lists/listinfo/stripes-users
An HTML attachment was scrubbed...
------------------------------
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
------------------------------
Subject: Digest Footer
_______________________________________________
Stripes-users mailing list
Stripes-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users
------------------------------
End of Stripes-users Digest, Vol 124, Issue 2
*********************************************