Route web Node.js + Vagrant + Nginx -
i have 3 instances of coreos in vagrant. in 1 of them have docker container node.js , other mongodb. node.js container has nginx configured , working if wget in container , in instance of coreos. question if have configure more show website in navigator, because can´t.
may have put router or else in vagrant?
first of all, want point out should apply seperation of concern, , split out nginx , node in seperate containers each responsible own tasks.
that leave nginx container, node container , mongodb container need link. can done in multiple ways. 1 of them bind port container exposing either hosts private or public ip address, , port on address.
that, in normal coreos setup should enable view webserver through ip address of host , port bound container port on. however, since vagrant ports should mapped too, have map 'real' hosts port, port on host.
steps achieve example: 1. map port 80 of localhost coreos vagrantboxes providing configuration in vagrantfile:
vagrant.configure("2") |config| config.vm.network "forwarded_port", guest: 80, host: 80 end
2. run container on coreos, , bind exposing port coreos:
docker run --name containername \ -p 80:80 imagename /cmd
now should able reach container going http://localhost in browser.
Comments
Post a Comment