This document is a technical guide that explores in detail the methods for delivering content from Contentstack to users in the China region, covering the challenges faced, solutions, and patterns.
For any internet traffic passing through the Great Firewall of China (GFW), a series of legislative measures and technologies are enforced by the Chinese government to regulate the internet domestically. This might cause the unreliability of data delivered by Contentstack’s API within China.
The GFW employs a variety of methods for internet censorship, which continues to evolve and change over time. These methods include:
These methods contribute to a highly sophisticated and adaptive system of internet censorship that companies and individuals must navigate when attempting to deliver content in China.
Using Contentstack APIs to serve content in China can face challenges due to the GFW. Here's an overview of possible issues:
To effectively deliver content to users in China while navigating the complexities of internet regulations, the following solutions and strategies offer a reliable approach.
Note: Customers must have a valid ICP license before they can run and deliver their website in China.
An architecture diagram is shown below representing the strategy to deploy content within China region:

To demonstrate the above steps, we utilize a Gatsby Starter app.
About the Gatsby Starter App: Gatsby is a widely used Static Site Generator (SSG) built on React, enabling developers to create fast and optimized websites by generating static HTML at build time.
Integration with Gatsby: Gatsby, being a static site generator, fetches content from Contentstack at build time to create static HTML pages. The stack created in Contentstack contains the content and assets required by Gatsby to generate the static pages.
A stack in Contentstack is a container that holds all the content, assets, and configurations needed for your project. For our example use case, we will use the Gatsby Starter app to add content to our stack.
By completing these steps, you will have a stack containing all the content, assets, and configurations needed for further development and customization.
In this step, we need to create a Jenkins server on an instance (Ubuntu22.04) in any cloud service provider or self-hosted datacenter and install NVM, Node, and Gatsby using the jenkins user.
Note: For simplicity, we have used Jenkins and AWS Cloud in this example. However, AWS Lambda or CodeBuild could also be used instead of Jenkins.
Create a Jenkins job build pipeline using the shell script:
pwd
whoami
# ----- Setting up Node.js path: -----
# path of node installation to be appended here. can be found with the command - 'whereis node'
PATH=$PATH:/var/lib/jenkins/.nvm/versions/node/v20.11.0/bin
echo $PATH
# ----- Creating .env.production file: -----
cat << EOF > .env.production
CONTENTSTACK_API_KEY=xxxxxx
CONTENTSTACK_DELIVERY_TOKEN=xxxxxx
CONTENTSTACK_ENVIRONMENT=development
# For live preview
CONTENTSTACK_MANAGEMENT_TOKEN=xxxxxx
CONTENTSTACK_API_HOST=api.contentstack.io
CONTENTSTACK_APP_HOST=app.contentstack.com
CONTENTSTACK_LIVE_PREVIEW=true
CONTENTSTACK_LIVE_EDIT_TAGS=false
#sitemap generation
# For enabling live editing tags for this project set CONTENTSTACK LIVE PREVIEW=true by default it is set to false
# For EU region add CONTENTSTACK_APP_HOST=eu-app.contentstack.com
# For EU region add CONTENTSTACK_API_HOST=eu-api.contentstack.com
# By default branch=main, if a branch is not provided
CONTENTSTACK_BRANCH=main
# By default region=us, if a region is not provided
CONTENTSTACK_REGION=us
EOF
# ----- Updating Gatsby serve command: -----
# By default "gatsby serve" command serves only on localhost. This step will ensure it is served on a private, public IP interface.
sed -i 's/"serve": "gatsby serve"/"serve": "gatsby serve -H 0.0.0.0"/g' package.json
# ----- Installing dependencies and building the project: -----
npm install
npm run build
echo -e "\n\n ####### BUILD COMPLETED SUCCESSFULLY ####### \n\n"
# ----- Rsync to remote server: -----
echo -e "RSYNC TO CHINA STARTED... \n\n"
cd .. && rsync -avzhe ssh contentstack-gatsby-starter-app-build root@<EIP-of-the-China-server-created-in-next-step>:/root/
echo -e "SYNC COMPLETED SUCCESSFULLY... \n\n"
Other configurations of this pipeline:


Webhook configuration in the stack:

HTTP Basic Auth Username: <csgatsbyremoteuser>
Email Addresses to Notify: <YOUR_EMAIL_ADDRESSES>

Now we should be able to trigger the build whenever anything is published in the main branch of the stack in the development environment.
[Unit]
Description=gatsby-serve service
After=network.target
[Service]
User=root
# Here's where the build is synced from Jenkins
WorkingDirectory=/root/contentstack-gatsby-starter-app-build
ExecStart=/usr/bin/npm run serve
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
Make any changes in the stack by publishing an entry or asset and it should reflect in the webpage within some minutes automatically without any downtime.
Here are some options that can help legally accelerate and optimize your site for the Chinese audience: