In http proxy environments,
the machinebox/facebox docker image never displays "machine is ready" in the log.
Accessing the UI works but it is impossible to use the API (eg. to teach)
How to reproduce
$ docker run --rm -ti -p 8080:8080 -e no_proxy=localhost -e http_proxy=${http_proxy} -e https_proxy=${https_proxy} -e MB_KEY="XXXXXXXXX" machinebox/facebox
2019/01/18 14:07:45 Number of MB_WORKERS is set to 4
[INFO] starting...
Welcome to Facebox by Machine Box
(facebox 7f66aba)
Visit the console to see what this box can do:
http://localhost:8080
If you have any questions or feedback, get in touch:
https://machinebox.io/contact
Please consider buying a subscription:
https://machinebox.io/#pricing
Report bugs and issues:
https://github.com/machinebox/issues
Tell us what you build on Twitter @machineboxio
# log below happens when trying to use /teach API
[ERROR] (500) faceClient call error: box is not ready, try again later
Explanation
Looking in the http proxy logs, we can see that facebox tries to contact its workers at URL http://0.0.0.0:WORKERPORT/info .. This does not work because the http request is routed to the http proxy, which is not aware of the workers.
# tail of /var/log/squid/access.log
1547820499.053 1 10.0.3.1 TCP_MISS/503 3962 GET http://0.0.0.0:10001/info - HIER_DIRECT/0.0.0.0 text/html
1547820499.054 1 10.0.3.1 TCP_MISS/503 3962 GET http://0.0.0.0:10002/info - HIER_DIRECT/0.0.0.0 text/html
1547820499.055 1 10.0.3.1 TCP_MISS/503 3962 GET http://0.0.0.0:10004/info - HIER_DIRECT/0.0.0.0 text/html
1547820499.055 1 10.0.3.1 TCP_MISS/503 3962 GET http://0.0.0.0:10003/info - HIER_DIRECT/0.0.0.0 text/html
Workaround
I extended the machinebox/facebox docker image to use a custom entrypoint which looks like this:
#!/bin/sh
# mb-facebox never initializes if proxy_* environment variables are present
# the reason is that it tries to connect to workers using http://0.0.0.0:<workerport>/info
# which will fail if 0.0.0.0 is not listed in ${no_proxy}
if [ -n "${no_proxy}" ]
then
no_proxy="0.0.0.0,${no_proxy}"
else
no_proxy="0.0.0.0"
fi
export no_proxy
exec /app/facebox
Symptoms
In http proxy environments, the machinebox/facebox docker image never displays "machine is ready" in the log. Accessing the UI works but it is impossible to use the API (eg. to teach)
How to reproduce
Explanation
Looking in the http proxy logs, we can see that facebox tries to contact its workers at URL http://0.0.0.0:WORKERPORT/info .. This does not work because the http request is routed to the http proxy, which is not aware of the workers.
Workaround
I extended the machinebox/facebox docker image to use a custom entrypoint which looks like this: