I recently changed 2 things, not sure which one might influence the result.
a) I changed the password on my database for the doliuser
b) I upgraded from v20.0.2 to v20.0.4
As a result of that I had to regenerate a new API token for all my users that uses the API.
Anyway, this post is about something else, namely that today the API Explorer is not working, because it tries to connect to httpS://localhost which is not responding when you are running inside Dolibarrs official docker image
I did not change my container configuration, I still have this environment variable
--env DOLI_URL_ROOT="http://localhost/" \
It is the same from within the container
root@dolipod:/var/www/html# export | grep -i DOLI_URL_ROOT
declare -x DOLI_URL_ROOT="http://localhost/"
In front of my Dolibarr container I have an nginx that does reverse proxy for dolibarr and other containers. Nginx is who encrypts with HTTPS towards the internet, where as the connection between nginx and dolibarr is plain http and runs over a virtual network card.
My other containers can access the API, and if I am inside my dolibarr container and I use curl I get these results.
root@dolipod:/var/www/html# curl http://localhost/api/index.php/status ; echo ""
{"error":{"code":401,"message":"Unauthorized: Failed to login to API. No parameter 'HTTP_DOLAPIKEY' on HTTP header (and no parameter DOLAPIKEY in URL)."}}
root@dolipod:/var/www/html#
root@dolipod:/var/www/html# curl https://localhost/api/index.php/status ; echo ""
curl: (7) Failed to connect to localhost port 443: Connection refused
If I go into About Dolibarr
page under Home, Admin Tools, About Dolibarr then I see this different value for the URL Root
URL Root dolibarr_main_url_root http://localhost/dolibarr (currently overwritten by autodetected value: https://****.*****.*****/dolibarr)
Why does it think it is http://localhost/dolibarr when I have defined it as http://localhost/ ?
And is it because it is autodetected as httpS:// … that the API explorer also uses httpS on localhost?
Why does it keep thinking that the folder is /dolibarr/? I configured it as /
okay, the conf.php had this value
$dolibarr_main_url_root=‘http://localhost/dolibarr/’;
but once again, why does it add the /dolibarr/ when I use the global value for the container?
root@dolipod:/var/www/html# export | grep -i DOLI_URL_ROOT
declare -x DOLI_URL_ROOT="http://localhost/"
Changing conf.php did seem to make it stick - but it still uses httpS for the API - why?