HTTP/3 Premium CDN Setup for Magento Cloud Hosting

| September 3, 2019 | DevOps PaaS, Installer

Jelastic HTTP/3 Premium CDN (content delivery network) add-on leverages a highly interconnected global network, featuring massive bandwidth capacity, advanced caching and acceleration strategies, fast-routing IP Anycast technology for powerful and lightning-fast performance over the globe.

This CDN network spans the globe with 130+ Super PoPs (points of presence) located on 6 continents. Jelastic customers get premium traffic for the same price across all continents and countries with no surprising bills based on geographic locations.

Attaching CDN network to a website is a simple process while using Jelastic PaaS. In this tutorial, you’ll see how to do that with Premium CDN service to ensure extremely fast content distribution among your clients worldwide. The demo instruction is based on Magento Hosting package where this e-сommerce platform can be automatically installed in one click and hosted within Jelastic PaaS.

CDN Add-On Installation

1. Log in to Jelastic dashboard, open Marketplace, find the HTTP/3 Premium CDN Add-On and click Install.

HTTP/3 Premium CDN from marketplace

2. In the opened window, choose the environment (Magento, in our case) where CDN should be enabled, the preferred nodes layer and press Install.

HTTP/3 Premium CDN installation

Note: Pricing may vary depending on country and chosen service providers.

3. When the installation is finished, you will get a success popup window with the CDN URL in the following format:

${env.envName}-${sufix}.cdn.edgeport.net

where ${sufix} - is a code name of your Jelastic hosting provider automatically generated for the environment hostname upon add-on installation

During the first hour or less you may experience 404 error as it takes time for a new environment to be propagated across the CDN network.

Environment Configuration

Environment Configuration

Currently, only the LiteSpeed Web Server supports HTTP/3 protocol. For NGINX web server, this modern protocol is still in development. So in order to provide the highest possible performance for CDN integrated into the user's environment, in this tutorial we'll cover Magento cloud hosting based on LiteSpeed Web Server.

In order to make Magento static assets downloadable from CDN and to get the environment ready for production, do the following steps:

1. Install Magento with LiteSpeed Web Server. 
2. Attach a public IP address to allow the LiteSpeed Web Server responding via HTTP/3 high-speed protocol excluding Shared Load Balancer from the traffic chain.
3. Bind your custom domain via A record. Let’s take magento.customdomain.com as an example.
4. Install Let’s Encrypt SSL Add-On with your custom external domain. If your environment was using Built-in SSL you can turn it OFF via a dashboard.
5. Finally, we will make the static content of the website downloadable from PoPs by changing the base URL to the generated CDN one. In case of Magento, do the following:

  • Open Magento admin panel using link and credentials from the email received after installation
  • Click on STORES > Configuration > Web > Base URLs (Secure)

HTTP/3 Premium CDN Magento base urls

  • Change protocol for Secure Base URL field and replace the domain name you chose before environment installation with your custom domain name assigned via A record, e.g. magento.customdomain.com
  • Fill in the Base URLs (Secure) for Static View Files and for User Media Files fields with CDN URL which was issued for the environment respectively:https://{env.envName}-${sufix}.cdn.edgeport.net/pub/static/
    and
    https://{env.envName}-${sufix}.cdn.edgeport.net/pub/media/
  • Permit access to Magento admin panel via https

HTTP/3 Premium CDN magento https

  • To push all of the traffic via https only repeat the same steps for STORES > Configuration > Web > Base URLs section.

  • Finally, press Save Config to apply changes.

6. Billing job triggers every night, so the next day you can check the billing history.

HTTP/3 Premium CDN billing history

Bind Custom Domain to CDN

Once you've attached CDN service, it automatically generates a dedicated domain for your environment ${env.envName}-${sufix}.cdn.edgeport.net as it was described earlier. You can also bind a custom domain (e.g. cdn.magento.customdomain.com) via add-on settings. Let’s see how to do this.

1. Press the Add-Ons button of the application server instance.

HTTP/3 Premium CDN add-ons

2. Find CDN Add-On and press Configure.

HTTP/3 Premium CDN configuration

3. Fill in Custom CNAME field. You can specify multiple domains separating them by space or semicolon (;). Then follow the instructions on how to bind custom domain via CNAME record.

HTTP/3 Premium CDN bind custom domain

Once you’ve applied this, the static website content will be available via your custom domain.

High Availability Method

Within the above-mentioned add-on settings, you can also choose an appropriate method to ensure high-availability mode. 

  • Round Robin (RR) - even distribution of requests among available nodes.
  • Primary Failover (PF) - all requests are sent to the first node, if it becomes unavailable the requests are redirected to the next and so on.

HTTP/3 Premium CDN high availability

During horizontal scaling of the nodes in the application server layer, the platform automatically updates the records of available nodes inside CDN service. It eliminates the necessity to perform any manual actions during scaling events.

Purge, Purge All and Uninstall

For cache cleaning of the static assets at PoPs, we can use Purge or Purge All actions. Once the assets are deleted, the CDN begins downloading their fresh copies from an origin server.

HTTP/3 Premium CDN purging

Purge deletes specific assets within the specified path.

HTTP/3 Premium CDN purge

Meanwhile, Purge All deletes all static assets at the PoPs, just asking the user to confirm cache clearance. The cache renewal process is much faster compared to the first static assets propagation after Add-On installation.

Link Multiple Environments For Extra High-Availability

For multi environment solutions such as geo-distributed applications, the high availability is quite important for dynamic content as well as for static. So if you have the application which consists of two environments are fully synchronized, you can ensure its extra high availability with respect to the static assets cached at PoPs. It is implemented as a possibility to link several environments to the same CDN endpoint. In other words, CDN will be caching the static assets from several origins which are fully synced.  Follow the steps below to make the required settings:

1. Find the Premium CDN add-on for the second environment and initiate installation.

HTTP/3 Premium CDN install add-on

Choose Link to an existing environment option and pick the environment with previously installed CDN add-on and click on Install button.

HTTP/3 Premium CDN link environment

2. Once deployed, a successful installation window appears with the CDN URL which actually refers to the same endpoint the existing environment does.

HTTP/3 Premium CDN installed successfully

Thus the HA mode is achieved with duplicated origins:

magento.jelastic.cloud

magento1.jelastic.cloud

So, if one goes down the other will be serving CDN’s requests for static assets caching at the single endpoint: magento-demo.cdn.edgeport.net.

3. The last step is to configure the second environment the same way so please repeat all of the configuration steps described above.

Congratulations! You’ve successfully integrated CDN onto your web sites that will make them lightning fast by loading data from the nearest geographic location. Explore the benefits at one of globally-available Jelastic service providers with Premium CDN Add-On support or contact your current Jelastic service provider to enable this functionality.