How can I get the IP address of users opening my heroku app? - heroku

Is there a way to view the IP addresses of people who have visited my web application which was deployed with heroku? swish-prophet.herokuapp.com

From within your app's code, you can get the IP address of the person making the request using the HTTP_X_FORWARDED_FOR HTTP header.
You can also see that information in your app logs with the heroku logs command.

You can use $_SERVER['REMOTE_ADDR'] with php.
But you need to consider that some users are behind a proxy system, so there's no way to register that users correct address.
Some websites use REMOTE_ADDR such as:
IP Chicken
Mi IP
Meu IP
My IP Address

Related

Prevent EC2 IP address redirecting for testing purposes

I'm trying to move my website over to AWS. I set up EC2 but I can't find a way to access the dev site I've set up to allow me to test it works before I switch over. The stack is Laravel/Forge and Nginx.
I have assigned an Elastic IP address, and I've enabled HTTP access via port 80. But when I go to the IP address it redirects to the live domain itself.
Same thing when I use the Public IPv4 DNS (ec2-<IP address>.compute-1.amazonaws.com).
I've been battling with it for some time. Can anyone advise what I'm doing wrong.

What source IP ranges to add to google cloud firewall to only allow access from the domain of my API

I currently have a Google cloud redis instance running which allows all connections ( ip range 0.0.0.0/0 ) which I would like to secure.
I have an api that is hosted on Heroku that is being forwarded to via a google domain. What I want to know is which ip do I add to the Source Ip ranges field in the google cloud firewall config tab to only allow connections from my API.
There are a few things I am confused about:
I need to specify an IP range, but I'm only going to be connecting to it from one IP ( The domain pointing to my API )
Which IP do I provide? The IP of my domain that is pointing to my API or the IP of the api instance itsself as it is on heroku?
Any help would be great!
Thanks
Heroku itself is hosted on AWS, so it uses a subset of their EC2 range.
Looking at this answer, you could use
heroku regions --json
to find the currently used IP ranges.
Problem with that: they can change!
If you need a static source IP coming from a Heroku app, you might want to use one of the SOCKS5 proxy addons.
But:
There is a performance impact for this cross-datacenter usage between your application and the Redis instance, so actually I would recommend you switching to a Redis instance by Heroku, or at least by a provider that lives inside the same AWS region.

API key does not allow access from IP (Heroku)

I'm currently trying to create a website that gets data from the Clash Royale game API (https://developer.clashroyale.com) but they ask my to give an IP address for my API authorization key.
The problem is that my website is hosted on Heroku, and Heroku has several (always changing and more than 10) IP's and I can only give 4 IP addresses on Clash Royale API.
When I give my person IP address and run my code the API is fetched without any problems, but when I push my code to Heroku and open my website, I get this error message:
Invalid authorization: API key does not allow access from IP xx.xxx.xxx.xxx
Is there any way to get a single IP address from Heroku so I can use always the same for my API authorization key?
I found the answer after hours of digging into the interweb :)
I simply used a thing called "Proximo" that apparently converges all of your websites possible IP's to one; see https://devcenter.heroku.com/articles/proximo

Get static IP address for Heroku app

I want to make a domain point to my Heroku app, so I am trying to create an A record that targets myapp.herokuapp.com.
The problem is that the domain provider requires an IP address, and I cannot find any IP address for my Heroku app. I guess it might be something about Heroku only having dynamic IP addresses (and thus no static IP addresses).
How can I fix this problem? Can I make Heroku use static IP addresses?

rails/devise: heroku app not recording user's ip addresses correctly?

All of the users in my app's Users table have signin IP addresses that are 'private' 10.x.x.x
So while devise is recording the IP address of a user when they signin, it appears to ACTUALLY be recording some sort of heroku internal IP address, probably related to the fancy grid architecture routing.
Does anyone know how my heroku-hosted app can record the actual incoming IP address?
It should be able to.
Something like this should yield the proper IP address:
ip = env[‘HTTP_X_REAL_IP’] ||= env[‘REMOTE_ADDR’]
The problem is because your app is behind a proxy or something like that.
Look at this patch: https://github.com/plataformatec/devise/pull/1398
It should solve the problem.

Resources