我使用带有trusty64
的流浪nginx, flask, gunicorn
框并且端口转发无法按预期工作
在vagrant文件中,我有:
config.vm.network "forwarded_port", guest: 8090, host: 3100
config.vm.network "private_network", ip: "10.10.1.10"
在盒子上,我跑了:
gunicorn myprj:app -b 10.10.1.10:8090
使用http://10.10.1.10:3100
尝试curl -v http://10.10.1.10:3100
会得到以下输出:
connect to 10.10.1.10 port 3100 failed: Connection refused
可通过主机
上的访客端口访问http://10.10.1.10:8090
我是流浪汉的新手,我错过了/乱七八糟的文件。
完成Vagrant文件:
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.box_check_update = false
config.vm.network "forwarded_port", guest: 8090, host: 3100
config.vm.network "private_network", ip: "10.10.1.10"
config.vm.synced_folder ".", "/vagrant_data"
config.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
vb.name = "lopamudra_dev"
end
config.vm.provision "shell", inline: <<-SHELL
# Upgrading the environment
apt-get update
apt-get upgrade
# Installing nginx + uwsgi + flask
apt-get install -y python-pip python-dev nginx
pip install uwsgi flask gunicorn
SHELL
end
答案 0 :(得分:0)
您正在将容器8090转发给hostIP:3100(localhost:3100) 同时你创建一个IP来访问10.10.1.10的容器,你的容器有8090暴露,这就是你可以在10.10.1.10:8090访问它的原因
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# NOTE: This will enable public access to the opened port
config.vm.network "forwarded_port", guest: 8090, host: 3100
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "10.10.1.10"