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 to point to the new server.
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.
Using Your Server's IP Address
To preview an app using your server's IP address, go to the app's Domains tab and add your server's IP address as one of the app's domain names.
If your server has multiple IP addresses or uses a DigitalOcean Floating IP, add the IP address you will make requests to using your browser even if that's not your server's primary IP address.
Using a Preview Domain
To preview an app using 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 Domains 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 184.108.40.206, add a wildcard A record for *.preview.srv1.devcompany.com that resolves to 220.127.116.11.
- Now, log in to ServerPilot.
- Go to the each app's Domains 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 18.104.22.168, you should create a wildcard DNS record for *.preview.srv2.devcompany.com that resolves to 22.214.171.124.
Last updated: July 19, 2017