You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Create new app via API call: what is "detached"? plus other questions... #55
I'm trying to create a new app via the CLI (or rather in a script), and see that I need to use a custom api call, as explained here and here.
When looking here for the right parameters to pass, I think it is the registerNewApp() method that is relevant. But what does the detached query string part mean?
detached means that the HTTP call returns as soon as CapRover engines receives the http call. Not passing detached causes the HTTP call to wait until the app is successfully created and setup before returning the HTTP call.
Note: It will not be possible to carry through with the 'caprover serversetup' if you've already forced https on your CapRover instance.
In such case go straight to logging in with the caprover login command. To change the password go to the settings menu in the app.
In my case the default .htaccess does indeed redirect all http to https. So it's not possible to run caprover serversetup? Why is that? It doesn't seem to have been a problem for me before. When I'm trying now, the first call of caprover serversetup --assumeYes --configFile config.json results in an error (html basically saying "nothing here yet"), but the second call of the same command does seem to set up the server OK.
And when creating an app, I'm trying to pass the whole config via a json file with caprover api --configFile myconfig.json, where myconfig.json is:
1- .htaccess ?? What is this for? CapRover doesn't use apache.
2- Regarding the api call: you cannot register the app and update the configs in one go. You have to first register the app. Wait a big and then update your config through calling user/apps/appDefinitions/update as mentioned in my comment above.
how true. I have no idea what is redirecting http to https then (type 302 redirect). DNS for this domain is handled by cloudflare, and "always use https" is definitely off. And when I run serversetup, why does the message "Enabling SSL..." show? I haven't done anything explicitly to enable SSL: . I'm also getting letsencrypt error messages now about too many attempts to create ssl cert for this captain domain... despite never having knowingly tried to enable ssl.
Also try experimenting to see if the issue is happening when you setup your server manually as well - or it's only happening when you're using the config file.
I now see why letsencrypt was setting up a certificate... I am of course passing an email via --certificateEmail, and this is a required parameter so I can't not. So it seems that https is mandatory on the caprover console.
try using a different root domain
I think that helped, but having done more attempts I'm not so sure, because I seem to get an error when I run serversetup for the first time on any root domain... or maybe different ones under the same domain (e.g. one.mydomain.com vs two.mydomain.com vs one.anotherdomain.com). See point (3) below.
Remaining questions:
(1) after doing caprover serversetup (and before each subsequent caprover api call), it seems that I need to caprover logout, or else it complains. It's not a big deal, but is there a way of avoiding this, and just taking the login credentials passed with the api call, without forcing a logout?
(2) usually I enable https on all apps that I create, but there doesn't seem to be a parameter for this in the update path? There is a forceSsl parameter but I assume that relates to the Force HTTPS by redirecting all HTTP traffic to HTTPS option on the app page rather than the Enable HTTPS button? Is there any way of enabling https on the app via the api call?
(3) is there any way of making this work for the same root domain again, even soon after the previous attempt? I am finding that if I try to use the same root domain again (or maybe even the same main domain but different sub-domain e.g. one.mydomain.com vs two.mydomain.com), I get an error the first time I call serversetup but if I run the same command again, it works.
So, when I delete the host server and spin up a new one, now when I run caprover serversetup first time I get:
And yes, I did give it plenty of time before running this, despite the Nothing here yet message in the above html.
Another time I saw:
Setup CapRover machine on your server...
- Enabling SSL... Takes a few seconds...
✖ Enabling SSL... Takes a few seconds...
Error Code: 1000 Message: Another operation is in process for Certbot. Please wait a few seconds and try again.
But when I run the very sameserversetup command again immediately, it goes fine:
Setup CapRover machine on your server...
CapRover server setup completed: it is available as greatname at https://captain.server.domain.com
For more details and docs see CapRover.com
So in my script I just run the serversetup twice, leaving a time gap in between, and it seems to work reliably.
Any idea why? Something to do with having set up ssl the previous time messing up the next time, even for e.g. one.mydomain.com and then two.mydomain.com? Why does it work second time? Any way avoiding this error completely, without the workaround of calling the setup command twice?
(1) after doing caprover serversetup (and before each subsequent caprover api call), it seems that I need to caprover logout, or else it complains. It's not a big deal, but is there a way of avoiding this, and just taking the login credentials passed with the api call, without forcing a logout?
What is the error message? And what are the steps to repro the isse?
(2) usually I enable https on all apps that I create, but there doesn't seem to be a parameter for this in the update path? There is a forceSsl parameter but I assume that relates to the Force HTTPS by redirecting all HTTP traffic to HTTPS option on the app page rather than the Enable HTTPS button? Is there any way of enabling https on the app via the api call?
There is enableSslForCustomDomain and enableSslForBaseDomain in the ApiManager class. All API calls are available there.
Regarding your 3rd issue:
It's not very clear to me how you're getting into that state. Basically what you're seeing should be applicable to "all serversetup calls". When you're using a different subdomain, it's a completely different domain in CapRover's view. Does the issue happen for a new domain as well? i.e. when:
You spin up a new server
You run caprover serversetup --assumeYes ...... with a brand new domain / or subdomain?
Is there any change you're recycling your old IP and you have a caching layer in the middle?
What is the error message? And what are the steps to repro the isse?
Actually it seems to be an info message and not an error message:
# caprover serversetup --assumeYes --configFile config-server.json
...
# caprover api --configFile config-app-register.json
Call generic CapRover API [Experimental Feature]...
Ensuring authentication...
Can't store store login credentials: https://captain.abc.mydomain.com already exist as abc in your currently logged in machines. If you want to replace the existing entry, you have to first use <logout> command, and then re-login.
API call completed successfully!
{}
So actually it seems that the call completes, so I can probably just ignore the message.
Re (2): thanks, I'll have a look at those.
Re (3):
Does the issue happen for a new domain as well?
It seems to work the first time for a new domain (rather than subdomain), but for subsequent server setups (even with a different subdomain name) the issue happens again.
Is there any change you're recycling your old IP and you have a caching layer in the middle?
Hmm, it's possible I suppose. Well it definitely is the case that the cloud server provider keeps re-allocating the same IP address to me, each time I spin up a new server (at least for today). DNS is handled by cloudflare, but the DNS entry is set to "DNS only" (not "Proxied") so I don't think there is any caching going on as such. But I suppose that re-using the IP for the new server might still cause its own issues. I would understand if it required a certain length of time to propagate, but the issue is solved by running caprover serversetup twice, rather than waiting any length of time.
Your setup is a bit complex, but basically what you're describing could be reproducible by simply wiping the CapRover server and reinstalling CapRover. This is the steps that are equivalent to what you're doing:
Create a brand new server
Install CapRover on the server
Run caprover serversetup on your local machine and setup your server
At this point the server is working fine and you can deploy apps if you choose too
Try setting up your server by running caprover serversetup on your local machine
At this point, you should observe the issue and get the 404 error.
Can you confirm if the issue is reproducible via running through these steps. If so, let's create a new issue with these exact repro steps and I'll look into it
After "remove and re-install CapRover", before running caprover serversetup using the same config file I have to caprover logout, but other than that, yes, the above steps do get me to the 404 error again.
Activity
githubsaturn commentedon Jun 14, 2020
detached means that the HTTP call returns as soon as CapRover engines receives the http call. Not passing
detachedcauses the HTTP call to wait until the app is successfully created and setup before returning the HTTP call.Clicking on Update and Save calls this method:
https://github.com/caprover/caprover-frontend/blob/5e9eede7b19478fe5542262dc52150ab18b4d66c/src/api/ApiManager.ts#L178-L218
All of the updates you want to perform are in this method.
drmrbrewer commentedon Jun 14, 2020
According to this:
In my case the default
.htaccessdoes indeed redirect all http to https. So it's not possible to runcaprover serversetup? Why is that? It doesn't seem to have been a problem for me before. When I'm trying now, the first call ofcaprover serversetup --assumeYes --configFile config.jsonresults in an error (html basically saying "nothing here yet"), but the second call of the same command does seem to set up the server OK.And when creating an app, I'm trying to pass the whole config via a json file with
caprover api --configFile myconfig.json, wheremyconfig.jsonis:This creates the app OK, with persistent data checked, but it doesn't add the env vars and ports. What am I doing wrong?
githubsaturn commentedon Jun 14, 2020
Two separate things here:
1-
.htaccess?? What is this for? CapRover doesn't use apache.2- Regarding the api call: you cannot register the app and update the configs in one go. You have to first register the app. Wait a big and then update your config through calling
user/apps/appDefinitions/updateas mentioned in my comment above.drmrbrewer commentedon Jun 14, 2020
how true. I have no idea what is redirecting http to https then (type 302 redirect). DNS for this domain is handled by cloudflare, and "always use https" is definitely off. And when I run serversetup, why does the message "Enabling SSL..." show? I haven't done anything explicitly to enable SSL:
. I'm also getting letsencrypt error messages now about too many attempts to create ssl cert for this captain domain... despite never having knowingly tried to enable ssl.
OK thanks.
githubsaturn commentedon Jun 14, 2020
Try using a different root domain.
Also try experimenting to see if the issue is happening when you setup your server manually as well - or it's only happening when you're using the config file.
drmrbrewer commentedon Jun 15, 2020
I now see why letsencrypt was setting up a certificate... I am of course passing an email via
--certificateEmail, and this is a required parameter so I can't not. So it seems that https is mandatory on the caprover console.I think that helped, but having done more attempts I'm not so sure, because I seem to get an error when I run
serversetupfor the first time on any root domain... or maybe different ones under the same domain (e.g.one.mydomain.comvstwo.mydomain.comvsone.anotherdomain.com). See point (3) below.Remaining questions:
(1) after doing
caprover serversetup(and before each subsequentcaprover apicall), it seems that I need tocaprover logout, or else it complains. It's not a big deal, but is there a way of avoiding this, and just taking the login credentials passed with the api call, without forcing a logout?(2) usually I enable https on all apps that I create, but there doesn't seem to be a parameter for this in the update path? There is a
forceSslparameter but I assume that relates to theForce HTTPS by redirecting all HTTP traffic to HTTPSoption on the app page rather than theEnable HTTPSbutton? Is there any way of enabling https on the app via the api call?(3) is there any way of making this work for the same root domain again, even soon after the previous attempt? I am finding that if I try to use the same root domain again (or maybe even the same main domain but different sub-domain e.g.
one.mydomain.comvstwo.mydomain.com), I get an error the first time I callserversetupbut if I run the same command again, it works.So, when I delete the host server and spin up a new one, now when I run
caprover serversetupfirst time I get:And yes, I did give it plenty of time before running this, despite the
Nothing here yetmessage in the above html.Another time I saw:
But when I run the very same
serversetupcommand again immediately, it goes fine:So in my script I just run the
serversetuptwice, leaving a time gap in between, and it seems to work reliably.Any idea why? Something to do with having set up ssl the previous time messing up the next time, even for e.g.
one.mydomain.comand thentwo.mydomain.com? Why does it work second time? Any way avoiding this error completely, without the workaround of calling the setup command twice?githubsaturn commentedon Jun 15, 2020
What is the error message? And what are the steps to repro the isse?
There is
enableSslForCustomDomainandenableSslForBaseDomainin the ApiManager class. All API calls are available there.Regarding your 3rd issue:
It's not very clear to me how you're getting into that state. Basically what you're seeing should be applicable to "all serversetup calls". When you're using a different subdomain, it's a completely different domain in CapRover's view. Does the issue happen for a new domain as well? i.e. when:
caprover serversetup --assumeYes ......with a brand new domain / or subdomain?Is there any change you're recycling your old IP and you have a caching layer in the middle?
drmrbrewer commentedon Jun 15, 2020
Re (1):
Actually it seems to be an info message and not an error message:
So actually it seems that the call completes, so I can probably just ignore the message.
Re (2): thanks, I'll have a look at those.
Re (3):
It seems to work the first time for a new domain (rather than subdomain), but for subsequent server setups (even with a different subdomain name) the issue happens again.
Hmm, it's possible I suppose. Well it definitely is the case that the cloud server provider keeps re-allocating the same IP address to me, each time I spin up a new server (at least for today). DNS is handled by cloudflare, but the DNS entry is set to "DNS only" (not "Proxied") so I don't think there is any caching going on as such. But I suppose that re-using the IP for the new server might still cause its own issues. I would understand if it required a certain length of time to propagate, but the issue is solved by running
caprover serversetuptwice, rather than waiting any length of time.githubsaturn commentedon Jun 16, 2020
Your setup is a bit complex, but basically what you're describing could be reproducible by simply wiping the CapRover server and reinstalling CapRover. This is the steps that are equivalent to what you're doing:
caprover serversetupon your local machine and setup your servercaprover serversetupon your local machineCan you confirm if the issue is reproducible via running through these steps. If so, let's create a new issue with these exact repro steps and I'll look into it
drmrbrewer commentedon Jun 17, 2020
After "remove and re-install CapRover", before running
caprover serversetupusing the same config file I have tocaprover logout, but other than that, yes, the above steps do get me to the 404 error again.