I have the following code that works great in my local environment. However, when I try to run the same code from a Docker container (via Boot2Docker), I simply cannot get to https://[boot2docker_ip]:4000
I tried updating the target value in the code below with all these options but none of them seemed to do the trick:
target: 'http://localhost:3000',
target: 'http://0.0.0.0:3000',
target: 'http://127.0.0.1:3000',
target: 'http://<boot2docker_ip>:3000',
var fs = require('fs');
require('http-proxy').createProxyServer({
ssl: {
key: fs.readFileSync(__dirname + '/certs/ssl.key', 'utf8'),
cert: fs.readFileSync(__dirname + '/certs/ssl.crt', 'utf8')
},
target: 'http://localhost:3000',
ws: true,
xfwd: true
}).listen(4000);
I am using the node-http-proxy
package from https://github.com/nodejitsu/node-http-proxy
Edit
Here is a Git repo to try out this behavior; I have checked in fake SSL for simplicity.
Dockerfile:
FROM readytalk/nodejs
ADD ./src /app
ADD ./ssl-proxy /proxy
COPY ./run.sh /run.sh
RUN chmod +x /run.sh
EXPOSE 3000
EXPOSE 4000
ENTRYPOINT ["/run.sh"]
run.sh:
#!/bin/sh
/nodejs/bin/node /app/main.js; /nodejs/bin/node /proxy/main.js
docker run
command that you're using to start the container might be useful. – Demy