Create a Simple Microsite
Traducciones al EspañolEstamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
This use case combines Linode’s and Akamai’s capabilities to create a complete end-to-end solution for a simple microsite. To build this application we’ll use Linode origin servers and an Akamai delivery product.
Akamai cloud computing based on Linode provides you with these benefits when creating a microsite:
- Simple and well-documented UI, CLI, and API provisioning capabilities.
- A clear pricing model that lets you estimate the cost for your compute needs.
- The simplicity of Linode combined with the scale of the Akamai CDN.
Architecture Overview
Prerequisites
This use case is for existing Akamai customers that want to learn how to use cloud computing based on Linode when building applications.
Linode Account
Before you start, make sure you have access to a Linode Cloud Manager account, either through your existing account or via a trial login. You can also sign up for a new account.
NoteTalk to your account representative or simply try the free credit available at the top of this guide.
If you’re new to Linode, watch this video to help you get started.
Entitlement for Ion
You also need access to an Akamai account with entitlement for Ion.
NoteTo see if you already have entitlement for Ion, log in to Akamai Control Center, go to > ACCOUNT ADMIN > Contracts. Click a Contract ID and search for Ion in the list of products.
Create a Linode
Create a Linode Compute instance to act as an origin server that will store content, messages, and other data for your microsite in the cloud.
NoteTo avoid an unexpected bill make sure to delete this Linode Compute Instance once you’ve completed this use case.
Log in to the Linode Cloud Manager and select the Marketplace link from the left navigation menu. This displays the Linode Create page with the Marketplace tab pre-selected.
You can read An Overview of the Linode Cloud Manager to learn more about features and services available in Linode’s Cloud Manager.
Use the Select an App field to search for the Node.js Marketplace App and select it.
Enter required information under the NodeJS Setup section. For more information and instructions refer to Guides - Deploying Node.js through the Linode Marketplace.
Note
This guide involves configuring DNS settings and SSL certificates for your domain. These steps can be automated during the Marketplace App installation process by providing a Linode API Token during setup.
During installation, the API Token is used to generate a domain zone and records using Linode DNS Manager. The Node.js Marketplace App then utilizes certbot to generate SSL certificates for your domain and subdomain.
If you plan to utilize Linode DNS Manager, we recommend taking steps now familiarize yourself with our DNS Manager guide.
Select “Ubuntu 20.04 LTS” in the Select an Image section.
Select a region.
Select the Shared CPU Linode 2GB Linode Plan.
Enter a root password.
Select any SSH keys for root access. For more information, refer to the Cloud Manager guide: Manage SSH Keys.
Select Private IP under Add-ons.
Click the Create Linode button at the bottom of the page.
Verify Marketplace App installation before continuing with this guide. It may take several minutes for installation to complete.
Note
You can also create a Linode Compute instance using these options:
Create a new Linux machine and install and set up a custom web server. For more information and instructions, refer to Creating a Compute Instance.
Select your preferred web server from Linode Marketplace to get a fully configured web server. For more information and instructions, refer to Marketplace Apps - Get Started.
To learn how to manually get an SSL certificate for your web server, refer to the Enabling HTTPS Using Certbot with NGINX guide.
Note
Create an Ion Property
Set up a delivery property to determine how your microsite will be delivered to requesting clients. We’ll use the Akamai setup wizard to do this.
Begin the Ion Setup Wizard
Start the setup wizard by following the instructions in Create a new guided Ion property.
Enter the FQDN of your Linode origin server as the Hostname. In this guide, we use the example domain
www.test.com
.In the Origin Server section select Web server as the Origin hostname and accept the suggested value for the Origin hostname.
Configure the Origin Hostname for your Linode
Add the origin hostname to your origin server domain’s DNS settings.
For example, if your Linode IP address is
203.0.113.1
and the suggested origin hostname isorigin-0361ece-www.test.com
, your Linode DNS Manager domain zone needs to have an A record with the following values according to your choice of primary domain:Primary Domain Record Type Hostname IP Address test.com
A/AAAA origin-0361ece-www
203.0.113.1 Verify your new origin hostname DNS configuration. For instructions, see the Use dig to Perform Manual DNS Queries guide.
Update your web server to include the origin hostname.
For example, if you are using NGINX, add the full hostname to the
server_name
entry as below:- File: /etc/nginx/sites-enabled/*
1 2 3 4
server { server_name origin-0361ece-www.test.com test.com www.test.com; ...
Then reload NGINX.
systemctl reload nginx
Next, update your origin certificate to include the Origin hostname and reload your web server.
If using the Node.js Marketplace App, access your origin server via LISH or SSH connection, replacing the example hostnames with your own:
certbot --expand -d www.test.com -d origin-0361ece-www.test.com
Select
1: No redirect
when prompted to complete SSL certificate configuration, then reload your NGINX server:systemctl reload nginx
While you are connected, rename the Linode’s system hostname to help identify it later:
hostnamectl set-hostname server1
Complete the Ion Setup Wizard
In the Ion setup wizard ORIGIN SERVER window, select Validate.
Continue to the EDGE CERTIFICATE configuration in the Ion setup wizard.
Select Standard TLS and add the following TXT record to the FQDN domain zone as guided.
If using Linode DNS Manager, create a TXT record in a domain zone for the Linode’s full hostname. Refer to the following example settings:
Primary Domain Record Type Hostname Value www.test.com
TXT _acme-challenge
Enter Record Value Note
Ensure that there no extra empty spaces when entering the Record Value.Verify your domain validation DNS record, then click the Validate button.
Continue through the Ion setup wizard by selecting default values for remaining prompts.
When you reach the Review and activate step, click Activate to enable your Ion configuration and Edge certificates.
This process takes several minutes to complete. Wait for the Next button to appear, then click it to continue.
Once your Ion configuration is activated, your Ion property should now include an Edge hostname such as
www.test.com.edgesuite.net
. Follow the instructions under the Verify section of the Ion setup wizard to test connectivity directly to your Edge hostname’s IP address by updating your local hosts file. If the IP address for your Edge hostname does not appear before your domain under Hosts file entry as shown in the screen capture below, refresh the page until it does.After you complete the test, remove the line you added to your local hosts file and click Next.
Note
You can also test with staging IP addresses for your Edge hostname. For example, if your edge hostname is
www.test.com.edgesuite.net
, its staging hostname iswww.test.com.edgesuite-staging.net
.Run the
nslookup
ordig
commands on the staging hostname as shown below.dig www.test.com.edgesuite-staging.net +short nslookup www.test.com.edgesuite-staging.net
As a result, you will see two staging IP addresses. Add either of them to your local hosts file along with your domain and perform the same Verify section browser test.
Replace existing DNS A/AAAA records with an alias to direct your Ion property hostname to your new Edge hostname.
If using Linode DNS Manager, you must first remove all A/AAAA records and primary domain zones for your Ion property hostname, then create a CNAME record according to the following example values:
Primary Domain Record Type Hostname Value test.com
CNAME www
www.test.com.edgesuite.net
Verify your DNS configuration changes, then click Check CNAME in the Ion setup wizard. Once your CNAME record is confirmed, requests to your domain should now route through Akamai’s Edge CDN.
Set Up High Availability
High availability is a term used to describe server setups that eliminate single points of failure. The following sections provide instructions for setting up multiple backend servers behind a NodeBalancer, then redirecting traffic from your Ion property to the NodeBalancer by adjusting DNS settings.
NoteNodeBalancers communicate with backend nodes through their private IPv4 addresses via HTTP.
Before you start, ensure your origin server supports HTTP port 80.
If you created your Linodes using Node.js from the Marketplace Apps, you can watch this interactive guide for more information.
Create Multiple Origin Servers
This section involves cloning your Linode origin server to provide high availability through redundancy.
NoteClustering files or databases is not in the scope of this use case. You can, however, refer to the Host a Website with High Availability guide if you want to learn more.
If you want to use a solution such as GlusterFS, instead of cloning the origin server you need to follow the instructions in Create a Linode to create two or more new Linode Compute Instances.
Log in to the Linode Cloud Manager.
Use the Linode cloning feature to create another Linode origin server in the same region.
For instructions, refer to Cloning a Linode.
Under Select Linode to Clone From, click the Linode you created for the web server in Create a Linode.
Select the same Linode Plan option you previously selected and click Create Linode.
Add a Private IPv4 Address to the cloned Linode.
Select Power On for the cloned Linode after creation is complete.
Ensure that the web server is running on your cloned Linode.
If using the Node.js Marketplace App, LISH or SSH into the cloned Linode and start the Node.js server as a background process:
node /opt/nodejs/hello.js &
You can also rename the cloned Linode hostname to help identify it later:
hostnamectl set-hostname server2
Set Up Network Load Balancing
Linode NodeBalancers distribute user requests between compute instances to improve capacity, performance, and availability. For more information, refer to the Getting Started with NodeBalancers guide.
NoteBefore you start, make sure that each of your origin servers has a private IPv4 address. For more information and instructions on how to add private IPv4 addresses to your origin servers, refer to the Managing IP addresses guide.
Log in to the Linode Cloud Manager.
Navigate to the NodeBalancer page and click Create NodeBalancer.
Select the same region you selected for your backend Linode instances.
In the Port Configuration section, change Port from
80
to443
.Change the Protocol from
HTTP
toHTTPS
.In the SSL Certificate section, paste the PEM-formatted contents of your web server SSL certificate.
Note
If using the Node.js Marketplace App, certificate files are located in the
/etc/letsencrypt/live/domain/
directory on your origin servers. Use the contentsfullchain.pem
andprivkey.pem
when configuring your NodeBalancer.Otherwise, to learn how to get an SSL certificate, refer to the Enabling HTTPS Using Certbot with NGINX guide.
In the Private Key section, paste the PEM-formatted contents of your webserver private key. Your private key cannot have a passphrase.
Select “Least Connection” for the Algorithm setting and “HTTP Cookie” for the Session Stickiness setting.
Note
To enable Forward Secrecy for SSL/TLS connections, follow the instructions in the NodeBalancer SSL Configuration guide.
If using the Node.js Marketplace app, Diffie-Hellman parameters are located on the Linode origin server in the
/etc/letsencrypt/ssl-dhparams.pem
file by default.In the Active Health Checks section, select the “HTTP Status” for the Type setting and enter a forward slash (
/
) as the Check HTTP Path.Note
Make sure all the origin servers listen to HTTP, not HTTPS, otherwise the HTTP Status option will not work.In the Backend Nodes section, select the Enter IP Address dropdown menu and select private IP address for the first web server.
Enter a label. For example,
Server1
.Enter the HTTP port number of the web server under the Port section.
Click Add a Node, and add the second web server.
Review the configuration, and click the Create NodeBalancer button.
Make note of the IP Address of the NodeBalancer.
Redirect your Ion origin hostname DNS A record to point to your NodeBalancer IP address.
If using Linode DNS Manager, the following settings apply for the example
www.test.com
domain and NodeBalancer IP address of203.0.113.2
according to the choice of primary domain:Primary Domain Record Type Hostname IP Address test.com
A/AAAA origin-0361ece-www
203.0.113.2 Note
For more information on configuration options, see the TLS/SSL Termination on NodeBalancers guide.
Test Your Origin
Complete these steps to test your Linode origin servers.
Create Test Pages
You can use a dynamic or static page to test your Linode origin servers.
To test using dynamic pages, create a page for each of your origin servers. It should show a unique characteristic of the origin servers, such as the server IP address or hostname.
For example, if you used Node.js Marketplace App to create your Linode, you can edit the
/opt/nodejs/hello.js
file for each backend Linode and restart Node.js:- File: /opt/nodejs/hello.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
const http = require('http'); const hostname = 'localhost'; const port = 3000; const os = require('os'); //Add the following line: const servername = os.hostname(); const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/html'); //Update the following line as shown below: res.end('Hello World @'+servername); }); server.listen(port, hostname, () => { console.log(); });
To test using a static page, create a unique html page for each of your Linode origin servers. The pages can simply include text to help you identify each of the origin servers. For example,
server1
andserver2
.- File: index.html for server1
1 2 3 4 5 6 7 8 9 10 11 12 13
<!DOCTYPE html> <html> <head> <title>server1</title> </head> <body> Welcome to server1! </body> </html>
- File: index.html for server2
1 2 3 4 5 6 7 8 9 10 11 12 13
<!DOCTYPE html> <html> <head> <title>server2</title> </head> <body> Welcome to server2! </body> </html>
Test Session Stickiness
Open the test page URL using a web browser that supports HTTP cookies. For example, if you have the Node.js test page above and your origin hostname is
origin-0361ece-www.test.com
, your test page URL ishttps://origin-0361ece-www.test.com/
.Reload the page a few times. You should receive all responses from the same origin server.
Open a new browser window in private/incognito mode or delete your web browser cookies and test again.
Repeat step 2, until you see a new response coming from a different origin server.
Test Failover
To test failover, shut down one of your origin servers by selecting Power Off for the desired Linode.
Repeat the steps in Test Session Stickiness. You should only get a response from active origin servers.
For more information on testing options, refer to the Ion documentation.
Learn More
You can also view the instructions for this use case in the Akamai techdocs.
To participate in a series of interactive modules that will guide you through the steps to get started with Akamai cloud computing based on Linode, go to the Build on Akamai training. You can use your Akamai Control Center login credentials to access the site.
This page was originally published on