Accessing Google API over CEN

By Vikram Godse, Solution Architect

Alibaba Cloud Cloud Enterprise Network (CEN) provides connectivity to Alibaba Cloud Virtual Private Clouds (VPCs) across the globe. This provides low latency bandwidth in addition to cross border connectivity to workloads from any international Alibaba Cloud Region into Alibaba Cloud in China

For users who have their apps built around the Google API’s there is a bit of configuration required to get it working from China. This article shows how to configure a Reverse Proxy to Access Google API’s from China over Alibaba Cloud CEN.

This approach is only to showcase accessing the custom API’s developed by an organization and hosted on Google API Gateway. In the long term, it is recommended that the custom API’s be moved to Alibaba Cloud API Gateway.


Architecture Overview

The diagram above depicts the overall connectivity between the Alibaba Cloud regions between Beijing and London and the connectivity to Google API over the internet

Initial Setup

Setup two hostnames in the /etc/hosts file on the Beijing server pointing to the London server for eg.

These hostnames will be the Virtual hosts that we will configure on the London Webserver, one each for the Google Translate and Text-to-Speech API’s

Install and Configure Apache

Install Apache on the Centos Server in London

The modules that are needed to use Apache as a reverse proxy include mod_proxy itself and several of its add-on modules, which extend its functionality to support different network protocols. Specifically, we will be using:

All these modules are enabled by default, but we can check the modules installed

If any of the modules are not listed you can enable them by editing the /etc/httpd/conf.modules.d/00-proxy.conf

And un-commenting the required modules by removing the #

Save the file and then restart the httpd service

For SSL to be supported you need to install mod_ssl

Configure Apache for Reverse Proxy

Setup two virtual hosts one for the “Google Translate API” and another for the “Text-to-Speech” API

Create an Apache Config file in the /etc/httpd/conf.d/google-translate.conf and make the following entries

The request for google translate will be received by this virtual host “” over the CEN, which is in London and it will proxy the request to Google Translate over https using the Google API URL It will forward the URL context as it has received from the request.

An example request to translate some content from English to German is shown in the following diagram

We can create another Virtual host for Google-Text-to-Speech API

Create another virtual host by creating another configuration file /etc/httpd/conf.d/textospeech.conf and make the following entries

Restart the httpd server after making the virtual host entry.

Now from the server in Beijing when we have to call the Text-to-Speech API we will call which is our reverse proxy virtual host in London.

This reverse proxy will proxy the request to

It will include the URL context that is received in the host header and forward it to google.

Following is a sample call that will convert some text in French to a voice file in base64 text format which can be decoded to generate the MP3 voice file

The voice file in base64 format looks as follows

Using base64 we can decode the file to a binary mp3 format audio file

The output file is as the audio.mp3 file


In this article, we showed the configuration for accessing Google API’s from Alibaba Cloud in China using Cloud Enterprise Network (CEN). However this exercise has been created for users who are using googleapi to host their custom API’s outside China and want to use the same API’s in China. You are recommended to move the API’s to Alibaba Cloud API Gateway in the long term.

Further Reading

Apache Reverse Proxy Guide


Follow me to keep abreast with the latest technology news, industry insights, and developer trends.