Accessing data using Dynamic IP from API which allows only static IP - python

I made a script which accesses some data from an API. The problem is that to access the API I have to visit their website and enter my IP in allowed IPs list to get the authorization key for that specific IP. There no such option to allow all IPs. Now my script is running on PythonAnywhere which is a free cloud service and doesn't provide static IP. So any idea how I can get a static IP? or maybe any other free cloud service which provides static IP. I tried Heroku too with that QuotaGuard extension but it asks for credit card details first and I don't have one.
Is there any service out there which can be accessed from any IP address and then use a private IP to get content and deliver that content to me?

If the provider doesn't support giving you a static IP, you use a proxy server.
On Heroku there we have the fixie or quotaguard addons that could help here.

Related

My Flask python web application is not accessible from a domain name

I have programmed in python a web application using flask. I decided to deploy it from my home with a raspberry pi which runs the code continuously. I would like it to be accessible from a web browser and for that I have thought to configure my router to redirect the requests to my server. I also took care to configure my firewall accordingly. It turns out that the application works well and is perfectly accessible by typing its public IP in my URL bar. The problem is that I can't access it using a domain name. I have rented a new one and I have configured the DNS records so that it points to my server. I tested the DNS servers and it seems that the pointing is effective. However, when I enter the domain name I don't get my web application but the page of hostinger, the hosting company where I rented the domain name. I have contacted the technical department and they assure me that the problem is not in the DNS but in the hosting, so in my python code. This leaves me perplexed because my web application is accessible from its public IP. So the code should be good.
Please do not hesitate to ask me for additional details, either on the level of my python program or on the level of my server.
Thanks in advance for your help

how to ip proxy in django route

There are websites like, "XYZ.com" and "ABC.com" and those websites can only be accessible with such a range of ip addresses.
We have public IP and using that third party website are accessible. (with only office premises we can access those website)
I have to develop a website (djangoproxy.com) in django so that I can access those third party websites from outside the public ip range.
so i plan to access those website like,
XYZ.djangoproxy.com,
ABC.djangoproxy.com
There is one condition, that access is based on only authenticated users. So I have to write code on djangoproxy.com for an authentic user. and after successfully login open a third party website in the same browser tab.
Had checked some python packages for vpn,
https://gist.github.com/Lazza/bbc15561b65c16db8ca8
Reference:
Python requests, change IP address
Can you guide me if this functionality can be developed using python code or any web-server configuration.
I am using NGINX as a web-server to host djangoproxy.com.
You can use django-revproxy for your purpose. Your Django server will sit between the client and the external website. You can add the authentication logic of Django and allow proxy for only authenticated clients.

Is it possible to migrate a google VM instance from one account to another keeping its external IP?

I am working in a python project that interacts both with the cloud and with an USB port. I hardcoded the VM IP in my python code, but I need to migrate the server from my personal account to the company's account. Because I deployed this python project as a .exe I have to build it again (with pyinstaller) in case I change the server IP. Is it possible to keep this IP after migrating?
It looks like Bring your own ip is possible
Best security practice, don't always keep public IP.
Internal/external IP identified with DNS server. Understand the objective and decide accordingly.
No, you can't keep the same IP from one project to another one (or you are very lucky). However, in this case, I recommend you to perform that:
Replace your billing account with the company billing account
Migrate the project from your organization to the company organization
Instead of recreate your project, simply change the ownership.
In the future, follow subbu recommendation: use domain name instead of IP!
I would first like to address that, for transferring and/or keeping public IP addresses from VM instances, you will need to then review the following documentation on reserving static external IP addresses, as an external IP address is the public IP address.
In your case, since you have public IP’s assigned to the VMs, you will need to then promote an ephemeral external IP address to a static external IP address; here you’ll find the documentation that demonstrates how to do this as well. This is how you can keep a public IP address for your instances.
Please keep in mind that, to preserve the same IPs after copying your VMs, you can do that if the instance is created in the same zone, so the new instance in the new project should be created in the same zone.
Moreover, in terms of moving VMs from one project to another, it is not possible, as VMs are binded to the project that they are located in. If you would like to move VMs from one organization to another, you will need to move the entire project to the end organization. You can follow this documentation to learn more about migration.

Unable to access public url from Google Cloud Platform

I am trying to access a public url from the Google Cloud Platform. But each time, I am getting connection timeout error. That URL is very well opening in my browsers and on different network as well. I am using Python to make a POST request to this URL and locally it is working fine. I don't know if need to set some security measures in Google or not.
Thanks and regards
Vipendra Singh Sengar
as mentioned here How to access websites that have ip block on GCP
By default, a Cloud Run service connects to external endpoints on the internet using a dynamic IP address pool.Which is problematic if you want to access an external website that requires connections originating from a static IP address, such as a database or API using an IP address-based firewall.
So you need to get an Static outbound IP address

Use ngrok url as callback url for facebook webhook, but is recognized "not whitelisted"

My IDE is Pycharm.
I want to test my app locally, so I run my service locally and use ngrok to expose my app to Internet.
The url showed by ngrok is https://436cb7e9.ngrok.io
But when I want to verify the facebook webhook callback url use this url above, it shows
ERROR 2017-12-27 08:16:37,407 wsgi_server.py:329] Request Host 436cb7e9.ngrok.io not whitelisted. Enabled hosts are set(['localhost'])
I ran the app well before, but I don't know why this time it shows an error.
Could somebody gives me suggestion?
After a bit of digging and thanks to Brady's comment about the gcloud version, I found out that all you need to fix this is to add a flag when you run your app.
So, say you run your app locally with:
python $APPENGINE/dev_appserver.py
just change it to:
python $APPENGINE/dev_appserver.py --enable_host_checking=false
and you should not have the host whitelist errors anymore.
For more information, checkout the release notes here: https://cloud.google.com/appengine/docs/standard/python/release-notes#december_5_2017
This seems to be working fine for me on gcloud 183.0.0 and 187.0.0 (the latest version at the time of writing of this comment).
It is done via the Auth tab of your ngrok dashboard. From IP Whitelisting Tunnel Access:
You may whitelist access to tunnel endpoints on your account. The
whitelist is enforced by the ngrok.com servers. It is applied globally
to all of your tunnel endpoints. Any incoming connection to any of
your tunnel endpoints is checked to guarantee that the source IP
address of the connection matches at least one entry in your
whitelist. If a connection does not match the whitelist it is
terminated immediately and never forwarded to an ngrok client.
As a special case, if your whitelist is empty, all connections are
allowed.
Managing the whitelist
You can manage the IP whitelist on the auth tab of your ngrok
dashboard. Enter a new IP address under the "IP Whitelist" section and
then click Add Whitelist Entry. Changes to the IP Whitelist can
take up to 30 seconds to take effect.
IP Ranges
Sometimes, you may wish to whitelist an entire range of IPs. Instead
of entering just a single IP address, you may instead specify a block
of IP addresses using CIDR notation. For example, to allow all IP
addresses from 10.1.2.0 to 10.1.2.255, you would add 10.1.2.0/24 to
your whitelist.
I had a slightly different question, but google lead me here none the less, the error I had was:
"The callback URL or verify token couldn't be validated. Please verify the provided information or try again later."
When trying to connect facebooks webhook to my localhost. Turns out I needed to authenticate my ngrok agent:
https://dashboard.ngrok.com/get-started/your-authtoken

Categories