Using the Google App Engine as a CDN


Google App Engine is Google’s platform for developing and hosting applications. To learn more, visit the Google App Engine home page. What matters to us in the service is its use, such as the CDN content delivery service, so you know Google servers are strong and fast, so why not take advantage of them, and I will discuss the steps of converting this service to a CDN in detail this method is old and was written on August 21, 2011. You can use Cloudflare instead, or maybe I will try the service again and update the explanation simple tip The service only allows you to view 5 million pages per month and 5GB of space. When this number of pages ends, your pages will stop displaying. This service is recommended for small blog owners only, from my point of view

Create a Google App Engine account

To create an account in the Google App Engine service, all you need is a Gmail account and register from the following page Google App Engine three steps just follow the following images:

GAE Sign up - WordPress Magazine
GAE signup email - WordPress Magazine

Create an app in Google App Engine

After creating the account, by logging in with your Gmail account, you will be presented with a page to create a new application

GAE create app - WordPress Magazine

When you click on Create Application, you will be directed to a page to verify your account by SMS. All you have to do is enter your mobile number and send it, then you will receive a short message on your mobile within a few seconds, but make sure to use the numbers for countries, for example, I am from Morocco, we have 212.

GAE Verify - WordPress Magazine
GAE authenticate - WordPress Magazine

After activation, the following page will be displayed:

GAE createapp - WordPress Magazine

As we note in the image, we choose the application’s identification name and check its availability. This name is like a subdomain in free hosting, for example.

http://mwordpress.appspot.com

As for the title, write what you want, and do not forget to agree to the terms of service after reading this if you have time to read it.

Download and install Google App Engine SDK and Python 2.5

At this stage, we will first need to install Python, specifically version 2.5 or above, because it is one of the requirements to run the Google App Engine SDK, and the installation method is of course easy, next etc.

python2 5 - WordPress Magazine

To download version 2.5.6, please visit the following page: Python Download Page

Secondly, we install the Google App Engine SDK, which we will need later to upload one of the projects that will help us in this important explanation. The installation method is simple, as usual in Windows, we do the next etc.

GAE install SDK - WordPress Magazine

To download version 1.5.3, please visit the following page: Download Google App Engine SDK for PythonBefore moving on to the stage, you must first install Python and then install the Google App Engine SDK This step is important in order to ensure that the CDN is set up properly

Add our own domain name to Google App Engine

This method is only if you want a website name to appear in the application instead of the link provided by the service. A simple example:

The link normally would be as follows:

http://mwordpress.appspot.com

We will change it to

http://cdn.mwordpress.com

The method is long and requires a little time and focus in order to add the domain well, frankly, it exhausted me a little at first because I added the subdomain directly and also for the first time to try this service and also I did not find any Arabic site talking about it when I registered for the first time, all the page was displayed in French or English, I do not remember the important thing, because this is the third time that I register to make this explanation.

google app engine add domain 001 - WordPress Magazine

Now that you have created the application, click on it as in

The picture is to go to the application control panel

google app engine add domain 0002 - WordPress Magazine

from

The menu on the left scroll to the bottom, specifically from the Administration menu, click on Application settings

google app engine add domain 0003 - WordPress Magazine

At the bottom you will find the option Domain setup as shown in the picture, click on it, click on it

google app engine add domain 004 - WordPress Magazine

Now you must subscribe to the Google Apps service.

The first service was only subscribing to the application engine and there is a difference between them because I go into explaining this difference because the explanation will be too long. Click on Sign up for Google App

google app engine add domain 005 - WordPress Magazine

As in the picture, enter the name of your main domain and do not add the subdomain in order to get into the problems of changing the Cname as happened with me and I had to delete the application and repeat the method again from the first important thing, then you will be transferred to the next page:

google app engine add domain 006 - WordPress Magazine

Fill in the data at your convenience

Use what you entered when subscribing to the Google App Engine service for the non-profit type. Now after completing the data, it will be transferred to the next page:

google app engine add domain 007 - WordPress Magazine

Here you should pay attention a little, because the admin account for Google Apps will be created with a new mail that you will need. For this, do not forget to save this account in a notebook with the password. The mail is as follows:

webmaster@mwordpress.net

All you have to do now is enter your username with a password and agree to the terms in order to move to the next page

google app engine add domain 008 - WordPress Magazine

Here we will change the account to the account that we created anew, after which it will automatically move to the next page:

google app engine add domain 009 - WordPress Magazine

The important thing here is to click on activate the Google App to

Go to the proof of ownership page:

google app engine add domain 010 - WordPress Magazine

Now download the file from Google

As in the picture and upload it via FTP or Cpanel to your main site folder and browse it to see if it was uploaded or not and then confirm the ownership

google app engine add domain 011 - WordPress Magazine

After confirmation, you will see a successful proof of ownership message

In the picture, we are now moving to the next plan. Focus with me a little. Click on Continue and sign out of Google apps

Now we will enter the control panel of the first Google Apps engine, not Google Apps, in order to show you a simple difference between them so that you do not get lost between the two services

  1. Google App Engine: We use regular Gmail
  2. Google Apps: We use mail with your domain name webmaster@sitename.com

This is a slight difference between the two services

Important After you log out of the Google Apps Control Panel, visit your application link on Google App Engine

http://[your-application].appspot.com

And log in with regular mail gmail and from the application control panel from the menu on the left go to the bottom Administration then Application Settings and then Domain Setup as we did in the first

google app engine add domain 012 - WordPress Magazine

Now add the domain, then we will move to

Google Apps login page

google app engine add domain 018 - WordPress Magazine

As we said before, your domain email

The one that we created in the previous steps. When you register in the Google Apps service, log in with the user name and you will automatically go to the next page:

google app engine add domain 013 - WordPress Magazine

tick

Upon approval, then activate the service. Now we will move to the next page for the settings of the application for the Google App Engine as shown in the following image:

google app engine add domain 014 - WordPress Magazine

Click on add a new URL, add a sub-domain name, for example, cdn

google app engine add domain 015 - WordPress Magazine

After adding the subdomain, you will see a message like the following:

Change your CNAME record To use the custom cdn.free-themes-wordpress-arabic.cz.cc URL, you must change your CNAME record by your domain host. Sign in to your domain hosting service. Go to the Domain Name Service (DNS) management page. The location and name of this page varies by host, but can generally be found in Domain Management or Advanced Settings. Find CNAME Settings and enter the following as a CNAME value or alias: cdn Set the CNAME destination to: ghs.google.com Save changes with your domain host and click “You have completed these steps” below. When done, click “You have completed these steps” to have Google check your CNAME history.

Do not click on “You have completed these steps” until we do the next step:

Here I will put the method through the Cpanel, log in to the control panel and then choose Simple DNS zone Editor as in the following image

google app engine add domain 016 - WordPress Magazine

Then use the sub-domain name that you have included in the application settings as in the previous image. Now after choosing Simple DNS zone Editor, add your sub-domain as in the following image and press Add CNAME Record

google app engine add domain 017 - WordPress Magazine

Now go back to the previous message page and click on “You have completed these steps” in order for Google to check the CNAME record.

Here we have finished adding our subdomain and as you can see the method is somewhat cumbersome and in any case you will also benefit from it in other applications if you want to use it

Note for a subdomain it may take up to 24 hours for a DNS update to take place

Installing CirruxCache and explaining the necessary settings

cirruxcache - WordPress Magazine

Praise be to God, because there is this CirruxCache project for programmer Samuel Alba, may God reward him for all the best. The project provides a temporary storage service for static files on the Google App Engine GAE. This idea has shortened us a lot of hard and traditional work when you want to upload static files to Google App Engine. In fact, it provides A lot of work is based on my personal experience and its settings are easy, and one of its advantages is that you install it and it searches a site for the files that you use and redirects to your application, for example, if the following file is requested:

http://mwordpress.net/wp-content/themes/themeNmae/style.css

The file (style.css) from our app will be displayed in Google App Engine and not just format files but all fixed files and even video files

http://mwordpress.appspot.com/wp-content/themes/themeNmae/style.css

In this way, it will be displayed quickly from the Google servers, which are characterized by flexibility and speed

If you use the subdomain, it will be shown like this:

http:// cdn . mwordpress.net /wp-content/themes/themeNmae/style.css

Here is some information about what the cirruxcache project does, as follows:

  1. honor Cache-Control
  2. cache TTL override
  3. several POP (Point Of Presence) configuration mapped on custom base-url
  4. ignore query string
  5. POST forwarding
  6. garbage collection of expired entries
  7. extensibility (develops your own WebServices on top)
  8. allow object flushing from restricted IP
  9. configure a POP (Point of Presence) according to a virtual host
  10. several behaviors (cache, redirect, forward)
  11. storage WebService (store big files <=2GB in order to be delivered)
  12. admin panel (flush objects, manage big files, statistics, config helper)
  13. image transformation (before caching it)

Download and setup CirruxCache

To download the project, all you have to do is visit this page CirruxCache Downloads and download the latest version

After downloading the copy, decompress it and copy the entire folder to the folder of the Google App Engine SDK that we installed before. Install it in the Program Files folder. Note the following image:

cirruxcache path - WordPress Magazine

And note the path of the project files and folders, how I put them in the CirruxCache folder so that you do not run into problems as I encountered before

cirruxcache path2 - WordPress Magazine

Now open the app.YAML file to change the name of the application for the explanation in the first picture when we chose the identification name for the application, the name was cdn-wp and at the end of the explanation, you will find me using cdnmwp. Do not look at the names that I use because I tried the method twice and took different pictures to explain what Concerning the name of the application that you created, the important thing is to change the name of the application in the file to the first name you used, as in the first picture in the explanation

application: appname

Change line 19 only to the name of your app

The important thing is now, we will move to preparing the config.py file for CirruxCache. The file will be found inside the folder. Open it with any text editor, for example notepadd++ and change the following code:

urls["default"] = (
#"(/debug/.*)", "Debug",
"(/data/.*)", "config.Static",
"/www(/.*)", "config.Www"
)

to me

urls["default"] = (
"(/wp-content/.*)", "config.Static",
"(/wp-includes/.*)", "config.Static",
"/(.*)", "config.Www"
)

In this case, all static files stored in Google App Engine will be shown, specifically in the two folders we changed wp-content and wp-includes for WordPress users

We will also change the following code for redirection and storage from:

class Static(cache.Service):
origin = "http://static.mydomain.tld"
maxTTL = 2592000 #1 month
ignoreQueryString = True

class Www(cache.Service):
origin = "http://www.mydomain.tld"
allowFlushFrom = ["127.0.0.1"]
forceTTL = 3600 #1 hour
ignoreQueryString = True
forwardPost = False

to the following code:

class Static(cache.Service):
origin = "http://sitename.com"
forceTTL = 2592000 #1 month
allowFlushFrom = ["127.0.0.1"]
ignoreQueryString = True
forwardPost = False
headerBlacklist = ["Set-Cookie"]

class Www(redirect.Service):
origin = "http://sitenam.com"

The important thing here is to change sitename.com to your main domain name, not sub, so as not to get into a problem. Save the file and we will move on to the next step, which is to upload the CirruxCache project after the modification we made to our application with the Google App Engine Launcher

Now launch the Google App Engine Launcher

GAE Launcher add existin app - WordPress Magazine
GAE Launcher add existin app browser - WordPress Magazine

The port number can be changed if it is busy or you are using your device as a proxy for a network or any other use. The important thing is that you can change it

Browse the location of the CirruxCache application by Google App Engine Launcher and add it, then we will place the mouse on the name of the application and click on Deploy as in the following image:

GAE Launcher deploy cirruxcache - WordPress Magazine

After clicking on Deploy, enter your email and password, and two windows will appear, one black and the other white (details, hehe, tell a story)

The important one you find in a message like this:

2011-08-21 00:18:55 Running command: "['C:\\Python25\\python.exe', '-u', 'C:\\Program Files\\Google\\google_appengine\\appcfg. py', '--no_cookies', u'--email= xxxxx @gmail.com', '--passin', 'update', u'C:\\Program Files\\Google\\google_appengine\\CirruxCache' ]"
Application: name-of-your-application ; version: 1
Host: appengine.google.com
Starting update of app: name-of-your-application , version: 1
Scanning files on local disk.
2011-08-21 00:19:19,427 WARNING appengine_rpc.py:435 ssl module not found.
Without the ssl module, the identity of the remote host cannot be verified, and
connections may NOT be secure. To fix this, please install the ssl module from
http://pypi.python.org/pypi/ssl.
To learn more, see http://code.google.com/appengine/kb/general.html#rpcssl .
Password for xxxx @gmail.com: Cloning 4 static files.
Cloning 39 application files.
Compilation starting.
Compilation completed.
Starting deployment.
Checking if deployment succeeded.
Will check again in 1 seconds.
Checking if deployment succeeded.
Will check again in 2 seconds.
Checking if deployment succeeded.
Deployment successful.
Checking if updated app version is serving.
Completed update of app: cdnmwp, version: 1
Uploading index definitions.
Uploading cron entries.
2011-08-21 00:19:50 (Process exited with code 0)

You can close this window now.

Now we have finished uploading the CirruxCache project application to the Google App Engine. To make sure that the service is ready, try any file from your site, for example, we have the following image:

http://mwordpress.net/wp-content/themes/1biztheme/images/ajax-loader.gif

We try it like this:

http://localhost:8080/wp-content/themes/1biztheme/images/ajax-loader.gif

If the image appears, your settings are correct, which means we will move to the last step

Change template links and plugins

This method, if you want to do it manually, will be very cumbersome. There are many links in the template and plugins. Fortunately, there are two plugins that will help you in this way.

WP Super Cache

This add-on I had explained here in this post from here, of course, the add-on contains the CDN property to rewrite all the links on the site and change them to another link. The following image and we save the settings

wp super cache cdn options - WordPress Magazine

CDN Linker lite

There is also this plugin in case you are not using WP Super Cache it also changes the blog link for all the files in wp-content and wp-includes I have not tried the plugin before and this is the link to its page on the WordPress.org website

CDN Linker lite addon page

end of transmission 😀

Here we have finished a detailed explanation of the use of using Google App Engine as a CDN. I hope that you will benefit from it. If there is any question or lack of explanation, please leave a comment. And don’t forget to subscribe to our mailing list, thank you very much

Leave a Comment