do you mean that Moodle 3.8 (latest) is not compatible with the same scenario that works with Moodle 3.7 (latest)?
That should be filed into the Tracker as a bug, if you can describe there the exact steps to replicate it - kind of summary of what written in this thread.
edited config.php + put "$CFG->ssl-proxy = true;" in the line above $CFG->www-root
Do you mean that you edited config.php just to add the new line $CFG->ssl-proxy = true;?
BTW any CLI command should run under the same user of the web server i.e. www-data in your case: https://docs.moodle.org/38/en/Administration_via_command_line#Running_CLI_scripts .