I installed ionic in a docker image. When running the container, I open the ports 8200 and 8100:
Then, in a browser, I can access http://localhost:8100 and see the ionic app. However, I can’t access the lab when I go to http://localhost:8200 the browser (firefox) says: “connection reset by peer”. If I try http://localhost:8300, the browser says “unable to connect”.
I’m guessing that requests on port 8200 arrive somewhere in the container but are refused in there.
When I run the following command, I still have nothing. (no log when accessing through port 8200, altough I have logs when accessing trhough 8100)
ionic serve --lab -c --verbose --host 0.0.0.0
Is there any way to check what is going on? I have no idea where to start looking. There is nothing on the /var/log of the container :-/
Thanks for your advice ,
EDIT: thats the result of netstat -tupln. Is there a hint I could exploit?
root@a71384711be9:/home/app# netstat -tupln | grep -E "8100|8200|Proto"
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8100 0.0.0.0:* LISTEN 205/node
tcp 0 0 127.0.0.1:8200 0.0.0.0:* LISTEN 237/ionic-lab
I found a workaround ^^
Since I think (but not sure) that ionic-lab only wants requests from within the same machine, I installed haproxy in the docker image to redirect requests from 0.0.0.0:1234 (from any) to 127.0.0.1:8200 (local == same machine). I can now access to the lab page using my browser at localhost:1234, because haproxy receives the requests from outside, and redirects to 127.0.0.1:8200. Since haproxy is inside the docker container, ionic-lab accepts requests from haproxy, which redirects to outside of the container.
I’m still wondering if I can access to the ionic lab without any proxy
If somebody knows the answer, I will be happy to know it
Here is the docker parts regarding the workaround I used:
RUN apt install -y haproxy
ADD haproxy.cfg /etc/haproxy/haproxy.cfg
haproxy.cfg: the default /etc/haproxy/haproxy.cfg file installed with haproxy, with theses lines appened
server localhost 127.0.0.1:8200
entrypoint: /bin/bash -c "service haproxy start && ionic serve --lab -c --host 0.0.0.0"
try command ionic cli, example: ionic serve --port 8100 --address=127.0.0.1
Fore it to be accessible on your host from dokcer, you need to run it with the address 0.0.0.0
ionic serve --port 8100 --address=0.0.0.0