How to Preview Apps before They Are Live
When migrating a website to a new server, you usually want to view the website before changing the domain's DNS point to the new server. When you only have one app on a server, you can just use the server's IP address (e.g., http://220.127.116.11). However, when you have more than one app on your server, only the default app is available using the server's IP address.
This tutorial will show you how to preview apps when you have more than one app on your server or when using a staging server.
Configuring a Preview Domain
The way to preview apps is to use a separate domain name for previewing.
To configure a preview domain name, complete these steps:
- Add the domain preview.YOURDOMAIN.com to your app's domains in ServerPilot. You can do this through the app's Settings tab.
- Where you manage your domain's DNS (for example, at your server provider), create a DNS A record for preview.YOURDOMAIN.com that points to your server's IP address.
Once you've completed the above steps and the DNS change has become active, you'll be able to view your app using the URL http://preview.YOURDOMAIN.com.
Note that the preview domain can be completely different than the live domain the app will use. For example, if your development company is devcompany.com and the app's domain will be yourclient.com, you can use a preview domain such as yourclient.devcompany.com.
Advanced: Using Wildcard DNS for Previewing Apps
If you have many apps on a server and you do not want to configure a separate DNS record for each one, you can create a wildcard DNS record that points to your server's IP address. Using this approach, you still need to add a specific preview subdomain for each app in ServerPilot, but you avoid needing to add a DNS record each time you create a new app.
Here's how you can set up preview domain names using wildcard DNS:
- Log in to where your DNS is hosted.
- If your server's hostname is srv1.devcompany.com and its IP address is 18.104.22.168, add a wildcard A record for *.preview.srv1.devcompany.com that resolves to 22.214.171.124.
- Now, log in to ServerPilot.
- Go to the each app's Settings tab and add a domain name such as APPNAME.preview.srv1.devcompany.com.
You can now preview each app using http://APPNAME.preview.srv1.devcompany.com.
When you add another app to your server, you do not need to make any DNS changes. You only need to add the domain name NEWAPPNAME.preview.srv1.devcompany.com to the new app in ServerPilot.
When you add another server to your ServerPilot account, you should create a new wildcard DNS record for that server. For example, if this new server's hostname is srv2.devcompany.com and its IP address is 126.96.36.199, you should create a wildcard DNS record for *.preview.srv2.devcompany.com that resolves to 188.8.131.52.
Last updated: April 26, 2017