OpenResty Edge includes a built-in authoritative DNS server, so you can host your domain’s DNS directly instead of relying on a third-party provider. From the Admin console you can add DNS records of several types (A, AAAA, CNAME, MX, TXT, NS, and more), route each resolution geographically by region or by CIDR range, and keep primary/backup records with automatic health checks that return only reachable results. This tutorial shows how to configure DNS records and geo-sensitive dispatch rules in OpenResty Edge, verify them with dig, and delegate your domain’s name servers to OpenResty Edge.

How to add a DNS record in OpenResty Edge

Let’s go to the OpenResty Edge’s Admin web console. This is our sample deployment of the console. Every user has her own deployment.

OpenResty Edge Admin web console — sample deployment

Go to the DNS management page.

Navigating to the DNS management page in OpenResty Edge Admin

Click on “openresty.net” to see how a DNS application works and how it is configured.

Overview of the openresty.net DNS application

First, you can see the DNS record mapping chart, which clearly shows the DNS resolution status in different regions.

DNS record mapping chart showing resolution status across regions

You can choose different subdomains here.

Selecting a subdomain in the DNS application

You can use this switch to toggle the mapping chart on or off.

Toggle switch for the DNS mapping chart

After clicking the “Add DNS record” button, a new record shows up in the list.

New DNS record added to the record list

The newly added DNS record row in the list

You can select the type of the record.

Selecting the DNS record type (A, AAAA, CNAME, MX, TXT, NS, CAA, or SRV)

And enter the subdomain of the record, such as “blog”.

Entering the record subdomain, such as blog

You can restrict the client addresses that can resolve this record.

Restricting the client addresses allowed to resolve the record

“Any” means do not restrict.

Choosing Any to apply no client restriction

Restrict by CIDR.

Restricting resolution by CIDR range

For example 192.168.1.1/24.

Entering a CIDR range such as 192.168.1.1/24

You can also choose the region here, Such as “Singapore”.

Selecting a region such as Singapore for the record

We do not have any restrictions this time.

No client restrictions applied to this record

Here is the resolution result, you can enter the IP address directly.

Entering the resolution result IP address directly

You can also choose one of the OpenResty Edge’s gateway clusters.

Choosing one of OpenResty Edge’s gateway clusters as the result

For example “aws-london”.

Selecting the aws-london gateway cluster

This is the expiration time of the record.

Setting the record expiration time (TTL)

You can select different time units for it.

Choosing the time unit for the record TTL

Here you can switch between primary and backup records. The backup record will be used if the primary record is missing or fails the health check.

Switching a record between primary and backup

OpenResty Edge also performs a health check on DNS records, which ensures that only available results are returned.

Enabling health checks on the DNS record

After you finish the configuration, click the button “Add”.

Clicking Add to save the DNS record

How to test DNS records with dig

Now let’s check the IP address of the gateway node in the DNS record that we just configured.

Checking the gateway node IP in the configured DNS record

As you see the IP ends with .240.

Gateway node IP ending in .240

Now use the “dig” command to do the DNS lookups.

The result shows that the IP of the gateway node matches the one in the gateway cluster that we chose.

dig output confirming the resolved IP matches the chosen gateway cluster

To get multiple results, you can add multiple DNS records.

Click the button “Add” again.

Adding a second DNS record

Enter the domain name “blog”.

Entering the domain name blog for the second record

Select another gateway cluster “aws-us-east”.

Selecting the aws-us-east gateway cluster

Click to add this record.

Saving the second DNS record

The domain “blog.openresty.net” has two DNS records now.

blog.openresty.net now resolving to two DNS records

Now go to the page “Gateway Cluster” and check the IP of “aws-us-east”.

The IP ends with .84.

aws-us-east gateway cluster IP ending in .84

Use the “dig” command to do the query again.

The result confirms the expected outcome.

dig confirming the second expected resolution result

You don’t need to create all DNS records manually. This button allows you to create a DNS plan based on the geographic location automatically.

Automatically generating a geo-based DNS plan

How to delegate your domain to OpenResty Edge’s authoritative DNS servers

Now, let’s continue the DNS configuration. Select the tab “Authoritative DNS Servers”.

Opening the Authoritative DNS Servers tab

Here we can configure the result of SOA.

Configuring the SOA record result

We will use a domain registrar as an example to show how to delegate your domain’s name servers to OpenResty Edge. The screenshots below use Google Domains, which has since been discontinued and migrated to Squarespace; the glue-record and custom-name-server steps are the same at any registrar. For a current, registrar-specific walkthrough, see the OpenResty Edge documentation (for example, Namesilo).

Using a domain registrar as an example to delegate name servers to OpenResty Edge

Select the tab “DNS”.

Selecting the DNS tab at the registrar

Select “Global DNS settings”.

Opening Global DNS settings

Add glue record, enter the domain name and OpenResty Edge Node IP.

Adding a glue record with the domain name and OpenResty Edge node IP

Go back to the previous page.

Returning to the previous page

Then select “Custom name servers”.

Selecting Custom name servers

Click to manage name servers.

Opening the name server management dialog

Enter the domain names that we configured in the “Global DNS Settings”.

Entering the name servers configured in Global DNS Settings

Click this button to switch to “Custom Domain Name Server”.

Switching to Custom Domain Name Server

You have successfully configured the registrar to delegate to OpenResty Edge.

Name server delegation successfully configured at the registrar

Let’s go back to OpenResty Edge Admin and continue with the DNS configuration.

The tab “User Group” is used for access control. For a full walkthrough of restricting who can manage each DNS application, see Control Access to DNS Applications in OpenResty Edge’s Admin Console.

The User Group tab used for DNS access control

Frequently asked questions

Does OpenResty Edge include its own authoritative DNS server?

Yes. OpenResty Edge has a built-in authoritative DNS server. You add and manage all records from the Admin console, and each record can resolve directly to one of your OpenResty Edge gateway clusters.

Can OpenResty Edge return different DNS results based on the client’s location?

Yes. Each DNS record can be scoped by region or by CIDR range, so you can direct users to the nearest gateway cluster. You can also generate a geo-based DNS plan automatically instead of adding every record by hand.

How does OpenResty Edge handle DNS failover?

Every record can be marked primary or backup, and OpenResty Edge health-checks the targets continuously. If a primary result is missing or fails its health check, the backup record is served, so only reachable addresses are returned.

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.