App Engine Proxy is a Node.js proxy server that uses node-http-proxy to modify and proxy URL Fetch requests. This solution was inspired by an integration with a third party that requires a dedicated IP for their firewall.
- clone
- cd app-engine-proxy
- npm install
- sudo nodejs app-engine-proxy.js
- npm install pm2
- pm2 start app-engine-proxy.js
- pm2 startup ubuntu
- pm2 save
GET / HTTP/1.1
Host: proxy.example.com
X-Target: https://csgapi.appspot.com/v1/med_supp/open/companies.json
Cache-Control: no-cache
The main thing to notice here is the addition of the "X-Target" header. This is the URI you wish to reach.
Optionally you may include the x-send-client-cert
header with a value of true
to send the certificates for client authentication.
curl https://csgapi.appspot.com/v1/med_supp/open/companies.json -x https://proxy.example.com/
url = 'https://csgapi.appspot.com/v1/med_supp/open/companies.json'
headers = {
'X-Target': url,
'x-send-client-cert': true
}
response = urlfetch.fetch('https://proxy.example.com/', headers=headers)
print(response.status_code)
print(response.content)