How to stage an edge application through the hosts file
Before you point your domain to Azion, you can stage running your application on the edge by changing the name resolution of your hosts
file. This way, you’ll have a chance to stage any changes and correct bugs before you publish your application using your custom domain.
Requirements
You’ll need:
- An edge application and a configured domain.
- A working internet connection.
sudo
privileges in your device.- A command line tool, such as Windows PowerShell or Mac Terminal.
- For Windows, a text-editing tool such as Notepad.
Step 1. Finding your edge node IP
To stage an application on the edge through the hosts
file, you must redirect your device’s DNS resolution to an edge node.
First, you need to find the IPs of the edge node where your application is being served. The node IP will change based on the edge node associated with your current location.
There are several ways to find your edge node IP, but the most common one is to use the host
command paired with your Azion domain.
The following command can be run on any Unix-based or Windows operating systems:
You’ll receive a response containing the Azion domain and one or more IP addresses of the edge node:
Step 2. Associating the edge node IP to a domain
Now you must associate the edge node IP to one or more CNAMEs that you’ve specified for your domain in your host configuration.
Windows
- Launch Notepad or any other text editing tool.
- Open the
hosts
file, which should be located inC:\Windows\System32\drivers\etc\
.
- Note that the
hosts
file is located in whichever drive Windows was installed and thus may not be the C: drive.
- Add a new line under the
localhost
line. - Paste the edge node IP into the first column.
- Add the CNAME you configured for the Azion domain to the second column. For example:
- Click on File > Save.
Linux
- Launch the terminal.
- In most Linux distributions, the terminal is located uder Applications > Utilities > Terminal.
- Type the following command to launch the
vim
text editor:
- Confirm your identity by typing your system password and press Enter.
- Use the arrow keys to navigate through the file.
- Add a new line under
localhost
. - Paste the edge node IP into the first column.
- Add the CNAME you configured for the Azion domain in the second column.
- Press Esc to switch to command mode.
- Type
:x
and press enter to save and exit thevim
terminal editor.
macOS
- Use the Launchpad to search for the Terminal app.
- Open the terminal and type the following command to launch the
nano
text editor:
- Confirm your identity by typing your system password and press Enter.
- Use the arrow keys to navigate through the file.
- Add a new line under
localhost
. - Paste the edge node IP into the first column.
- Add the CNAME you configured for the Azion domain in the second column.
For example:
- Press Ctrl+O to save your changes.
- Press Ctrl+X to exit the
nano
text editor.
Step 3. Staging your application
Once your hosts
file is configured, you’ll be able to access your application through the CNAMEs you provided using any browser in your device.
To avoid your browser from resolving your host name through cache, launch your browser using incognito mode, use a different browser, or clear browser cache before accessing the domain.
In the absence of cache, if your original application is already served on the CNAME you assigned but hasn’t undergone domain record modifications in the DNS provider, the hosts
file will serve the edge application using the custom host.
To access your staged application through a browser, in the search bar, navigate to the same CNAME you configured in your domain and in the hosts
file.
You should now see your Azion domain as if it was in production and perform any necessary tests before pointing your DNS resolution from your provider or migrating your authoritative nameservers to Azion.