Welcome ...
comment: without accurate description of server setup/systems involved all of it was a guess ... refer:
https://moodle.org/mod/forum/discuss.php?d=349805#p1412106
There was a question about proxy or reverse proxy settings earlier.
'spirit of sharing', Ken