I'm trying to access a site using Google Cloud Functions or Cloud Run.
But it looks like it's blocking the IPs coming from these services
Locally the code works fine. I've tried to add a lot of headers to simulate a local call, but it doesn't work.
Some of the headers:
--header 'Connection: keep-alive'
--header 'Accept: /'
--header 'X-Requested-With: XMLHttpRequest'
--header 'Origin: <site fororigin>'
--header 'Referer: <site for referer>'
--header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36'
--header 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8'
--header 'Sec-Fetch-Site: same-origin'
--header 'Sec-Fetch-Mode: cors'
--header 'Sec-Fetch-Dest: empty'
--header 'Accept-Language: pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7'
It also works if I create a VM on my region (south america) but this solution will create a lot of automation complexities
Is there a way to work around the Ip block? maybe by calling another server to change the IP?
I wrote the documentation on this topic which explains how to get a static IP address, which you can ask to be whitelisted, and use it for outbound connections on Cloud Run. https://cloud.google.com/run/docs/configuring/static-outbound-ip
This involves routing your external traffic through a VPC Connector to a VPC that has NAT configuration with one or more static IP addresses. That way, Cloud Run will be using those IPs when it connects to external endpoints.