Home > other >  Deploying Moodle Docker
Deploying Moodle Docker

Time:07-13

I'm using moodle-docker and trying to run it on a cloud VPS (virtual private server), I've bought a domain and link it to the public ip address provided by the VPS.

I've cloned a Moodle repository in the VPS and set up the moodle-docker to point to it like so

export MOODLE_DOCKER_WWWROOT=~/Sources/moodle &&
export MOODLE_DOCKER_DB=mysql &&
export MOODLE_DOCKER_WEB_HOST=my-domain.my.id &&
export MOODLE_DOCKER_WEB_PORT=8000

but when I open my-domain.my.id:8000 it give me error Connection refused. I also tried to use curl even from inside the VPS itself, here is the command:

curl -v -g 'http://my-domain.my.id:8000'

the result:

*   Trying 103.170.85.180:8000...
* TCP_NODELAY set
* connect to 103.170.85.180 port 8000 failed: Connection refused
* Failed to connect to my-domain.my.id port 8000: Connection refused
* Closing connection 0
curl: (7) Failed to connect to my-domain.my.id port 8000: Connection refused

I also tried to run a custom web server on it to make sure that I can access it from the internet. The web server run on port 8085, and i can curl it just fine:

curl -v -g 'http://my-domain.my.id:8085/ping'
*   Trying 103.170.85.180:8085...
* TCP_NODELAY set
* Connected to my-domain.my.id (103.170.85.180) port 8085 (#0)
> GET /ping HTTP/1.1
> Host: my-domain.my.id:8085
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
< Content-Type: application/json; charset=utf-8
< Content-Length: 54
< ETag: W/"36-wY0ccM5thB7kDQk7rQPWw2Kfc/Y"
< Date: Mon, 11 Jul 2022 03:45:35 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
< 
* Connection #0 to host my-domain.my.id left intact
{"status":"running","time":"2022-07-11T03:45:35.204Z"}

I've been tinkering for a few days with no result so if you have anything that i could try feel free to comment

CodePudding user response:

checking the list of running docker I noticed the ports on the web server that can be accesed is using 0.0.0.0:8085->8085/tcp and the moodle-docker is using 127.0.0.1:8000->80/tcp. I read the moodle-docker-compose and it's using 127.0.0.1 if bind ip is not specified.

So changing from

export MOODLE_DOCKER_WEB_PORT=8000

to

export MOODLE_DOCKER_WEB_PORT=0.0.0.0:8000

works for me but I'm not sure why. Can anyone explain why?

  • Related