I need to deploy my app (myappname) on domain say mydomain.com, but the app is by default available to public at:
http://myappname.captain.mydomain.com
How can I remove the previous default URL, so my app is only accessible through the top and second level domain names aka mydomain.com.
There are many ways of solving this issue but I don't think you can simply move caprover to the root domain. This app works very similarly to Heroku or Elastic Beanstalk, meaning that it provides a generic hostname for your app and you can point to it at the domain level.
So you could either have a CNAME record that points your mydomain.com to the myappname.captain.mydomain.com. You could also add a 301 redirect when a user (or search bot) visits the myappname domain that would redirect it to the mydomain.com domain. That way nobody can consume your website with the "wrong" domain.
If your goal is to completely hide the .captain.mydomain, I think that will be hard with the way caprover is meant to operate.
@osmanzeki Thank you for your reply. I however don't see the reason behind this, it would be helpful if there is any documentation or external resources to give a better idea... If CapRover is capable of adding mydomain.com to the default domain that points to the app, why am I not able to simply remove the default one?
As @osmanzeki said above, it's a common practice for many PaaS platforms. There is really no reason to remove it. If you don't want it, simply just don't use it. you can go a step further and return a 302 response code if the URL is the default appname.root.domain.com.
CapRover goes a step further compared to typical PaaS, like heroku, and it lets you completely modify the nginx configuration. In this case, if you really really don't want the default domain, you can override it by going to Apps > Your App > HTTP Settings and click on EDIT DEFAULT NGINX CONFIGURATION
<%
if (!s.forceSsl || s.hasSsl) {
%>
and change it to
<%
if (( s.publicDomain !== 'appname.root.domain.com' ) && (!s.forceSsl || s.hasSsl) ) {
%>
Of course, replace appname.root.domain.com with your own default domain.
Most helpful comment
There are many ways of solving this issue but I don't think you can simply move caprover to the root domain. This app works very similarly to Heroku or Elastic Beanstalk, meaning that it provides a generic hostname for your app and you can point to it at the domain level.
So you could either have a CNAME record that points your mydomain.com to the myappname.captain.mydomain.com. You could also add a 301 redirect when a user (or search bot) visits the myappname domain that would redirect it to the mydomain.com domain. That way nobody can consume your website with the "wrong" domain.
If your goal is to completely hide the .captain.mydomain, I think that will be hard with the way caprover is meant to operate.