This tutorial shows you how to use gateway staging servers in OpenResty Edge to test your gateway configuration changes before releasing them to all your production gateway servers.

What are staging servers

We know that Edge Admin manages and distributes configurations to Edge Servers. It could be problematic to distribute significant changes directly to all Edge Servers.

Embeded video

To solve this problem, we mark some Edge Servers as staging servers. First release changes to staging servers, and then release them to all servers after testing. It is our topic today: staging servers.

Embeded image

Let’s go to the OpenResty Edge’s Admin web console. It is our sample deployment of the console. Every user has their local deployment.

Screenshot

Set up gateway servers as staging servers

First, let’s see how to set up gateway servers as staging servers.

Click the tab Gateway Clusters to enter the page of Gateway Clusters.

Screenshot

Here we have a gateway cluster with two gateway servers.

Screenshot

Now we want to set up these two gateway servers as staging servers. We can achieve this in two ways. The first is to set up the whole gateway cluster as a staging cluster. Let me show you how to do this.

Click to edit this cluster.

Screenshot

Here is a switch to set up whether a cluster is a staging cluster.

Screenshot

This switch is off now.

To make the cluster staging, you need to turn this switch on.

Screenshot

Click to save this change.

Screenshot

Click on the cluster name to enter the server list page.

Screenshot

You can see from the server list page that these two servers are now staging servers.

Screenshot

Go back to the gateway clusters page.

Screenshot

The second way is to directly set up a gateway server as a staging server.

Click on the edit button again.

Screenshot

Turn this switch off.

Screenshot

We see that there are switches under each server to set up whether a server is a staging server.

Screenshot

Turn this switch on.

Screenshot

Click to save this change.

Screenshot

Click on the cluster name.

Screenshot

You can see that the first server is still a staging server.

Screenshot

The second server is not.

Screenshot

We do this just for the convenience of the demonstration. It is not recommended to have a cluster with both staging and non-staging servers. It will cause problems when releasing changes on the cluster level.

Release changes to staging servers

Now let’s go back to the applications page and see how to release changes to staging servers.

Screenshot

We use our ongoing sample application for the test-edge.com domain.

Screenshot

Let’s enter this application.

Screenshot

Here we create a new page rule to test the staging release.

Screenshot

Click to create this rule. This rule is to return specific content under a particular URI.

Screenshot

First, we add a condition for this rule.

Screenshot

The variable of the condition remains unchanged as URI.

Screenshot

We choose the string equality operator.

Screenshot

Screenshot

Enter the value /test to match this URI.

Screenshot

The condition is now complete.

Then for the action part of the rule, we can configure an output response body action. Please note that we chose this action just for demonstration. Staging servers work with any configuration.

Screenshot

We have a lot of actions here.

Screenshot

So better search for the Output action.

Screenshot

Select the action “Output response body”.

Screenshot

Select text/plain as the content type.

Screenshot

Screenshot

Enter “Hello World” as the output response body.

Screenshot

Click this option to insert this rule before any other existing rules.

Screenshot

Click the Create button to create this rule.

Screenshot

You can see that the rule is already there.

Screenshot

The last step is to make a new configuration release. It will push out our pending changes to our gateway servers.

Screenshot

Let’s click on this link to make a new release.

Screenshot

Add a comment for this release.

Screenshot

To do a staging release, you need to turn on this button.

Screenshot

All staging servers are listed here.

Screenshot

Ship it.

Screenshot

Now it is fully synchronized.

Screenshot

We still see changes we just made in the list of unreleased changes. This is because changes have not been released to all Edge Nodes but only to staging ones.

Screenshot

In the list of release history, we can see changes we just made.

Screenshot

And we can see that the release type is staging.

Screenshot

Test changes on staging servers

Now we go to the gateway clusters list and select the servers for testing.

Screenshot

Note that the server with an IP address ending with 226 is a staging server. Click to copy it.

Screenshot

Use this staging server

Screenshot

send the request

Screenshot

We add an “enter” as output to make the output clear.

Screenshot

You can see Hello World as the response.

Screenshot

Now let’s test with a non-staging server. Click to copy the server with the IP address ending with 213.

Screenshot

Use this non-staging server

Screenshot

You can see 404 as the output. It means that the changes we just made did not affect this server.

Screenshot

What is OpenResty Edge

OpenResty Edge is our all-in-one gateway software for microservices and distributed traffic architectures. It combines traffic management, private CDN construction, API gateway, security, and more to help you easily build, manage, and protect modern applications. OpenResty Edge delivers industry-leading performance and scalability to meet the demanding needs of high concurrency, high load scenarios. It supports scheduling containerized application traffic such as K8s and manages massive domains, making it easy to meet the needs of large websites and complex applications.

If you like this tutorial, please subscribe to this blog site and/or our YouTube channel. Thank you!

About The Author

Yichun Zhang (Github handle: agentzh), is the original creator of the OpenResty® open-source project and the CEO of OpenResty Inc..

Yichun is one of the earliest advocates and leaders of “open-source technology”. He worked at many internationally renowned tech companies, such as Cloudflare, Yahoo!. He is a pioneer of “edge computing”, “dynamic tracing” and “machine coding”, with over 22 years of programming and 16 years of open source experience. Yichun is well-known in the open-source space as the project leader of OpenResty®, adopted by more than 40 million global website domains.

OpenResty Inc., the enterprise software start-up founded by Yichun in 2017, has customers from some of the biggest companies in the world. Its flagship product, OpenResty XRay, is a non-invasive profiling and troubleshooting tool that significantly enhances and utilizes dynamic tracing technology. And its OpenResty Edge product is a powerful distributed traffic management and private CDN software product.

As an avid open-source contributor, Yichun has contributed more than a million lines of code to numerous open-source projects, including Linux kernel, Nginx, LuaJIT, GDB, SystemTap, LLVM, Perl, etc. He has also authored more than 60 open-source software libraries.