在主机上的vagrant virtualbox中访问django服务器?
我正在使用windows和putty通过ssh连接到vagrant virtualbox。我无法使用ssh访问在vagrant virtualbox中运行的django服务器 我也禁用了防火墙 这是我的流浪汉档案:在主机上的vagrant virtualbox中访问django服务器?,vagrant,virtualbox,portforwarding,vagrant-windows,zulip,Vagrant,Virtualbox,Portforwarding,Vagrant Windows,Zulip,我正在使用windows和putty通过ssh连接到vagrant virtualbox。我无法使用ssh访问在vagrant virtualbox中运行的django服务器 我也禁用了防火墙 这是我的流浪汉档案: VAGRANTFILE_API_VERSION = "2" def command?(name) `which #{name}` $?.success? end Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
VAGRANTFILE_API_VERSION = "2"
def command?(name)
`which #{name}`
$?.success?
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# For LXC. VirtualBox hosts use a different box, described below.
config.vm.box = "fgrehm/trusty64-lxc"
# The Zulip development environment runs on 9991 on the guest.
config.vm.network "forwarded_port", guest: 9991, host: 9991, host_ip: "127.0.0.1"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder ".", "/srv/zulip"
# Specify LXC provider before VirtualBox provider so it's preferred.
config.vm.provider "lxc" do |lxc|
if command? "lxc-ls"
LXC_VERSION = `lxc-ls --version`.strip unless defined? LXC_VERSION
if LXC_VERSION >= "1.1.0"
# Allow start without AppArmor, otherwise Box will not Start on Ubuntu 14.10
# see https://github.com/fgrehm/vagrant-lxc/issues/333
lxc.customize 'aa_allow_incomplete', 1
end
end
end
config.vm.provider "virtualbox" do |vb, override|
override.vm.box = "ubuntu/trusty64"
# 2GiB seemed reasonable here. The VM OOMs with only 1024MiB.
vb.memory = 2048
end
$provision_script = <<SCRIPT
set -x
set -e
sudo apt-get update
sudo apt-get install -y python-pbs
/usr/bin/python /srv/zulip/provision.py
SCRIPT
config.vm.provision "shell",
# We want provision.py to be run with the permissions of the vagrant user.
privileged: false,
inline: $provision_script
end
VAGRANTFILE\u API\u VERSION=“2”
def命令?(名称)
`哪个#{name}`
美元?成功?
结束
configure(Vagrant文件API版本)do | config|
#对于LXC。VirtualBox主机使用不同的框,如下所述。
config.vm.box=“fgrehm/trusty64 lxc”
#Zulip开发环境在客户机上运行于9991。
config.vm.network“forwarded_port”,guest:9991,host:9991,host_ip:“127.0.0.1”
config.vm.synced_文件夹“.”,“/vagrant”,已禁用:true
config.vm.synced_文件夹“,”/srv/zulip”
#在VirtualBox提供程序之前指定LXC提供程序,因此它是首选。
config.vm.provider“lxc”do | lxc|
如果命令?“lxc ls”
LXC_VERSION=`LXC ls--VERSION`.strip,除非已定义?LXC_版本
如果LXC_版本>=“1.1.0”
#允许在没有AppArmor的情况下启动,否则在Ubuntu14.10上不会启动Box
#看https://github.com/fgrehm/vagrant-lxc/issues/333
lxc.自定义“aa_允许_不完整”,1
结束
结束
结束
config.vm.provider“virtualbox”do | vb,覆盖|
override.vm.box=“ubuntu/trusty64”
#2GB在这里似乎是合理的。虚拟机OOMs只有1024MiB。
vb.memory=2048
结束
$provision_script=我建议(客人):
并了解哪些端口是开放的,以及拥有这些端口的流程。如果缺少所需的服务,请确保负责该服务的服务已启动,或者自己启动。从您的Vagrant文件的外观来看,这将是“Zulip开发环境”。我建议(在客户机上):
并了解哪些端口是开放的,以及拥有这些端口的流程。如果缺少所需的服务,请确保负责该服务的服务已启动,或者自己启动。从vagrant文件的外观来看,这将是“Zulip开发环境”。您尝试过吗?是的,它不起作用,因为您可以通过ssh连接到vagrant实例,我将假设provision.py存在问题,它实际上没有打开端口9991。您是否可以使用telnet或netcat之类的工具从vagrant机器内部访问localhost:9991?您是否有精简的/srv/zulip/provision.py文件?我不能启动一个流浪者和测试没有它。我猜端口9991被封锁,nc-z;回声$?给了我1作为输出,这表明端口失败。您尝试了吗?是的,它不工作,因为您可以通过ssh连接到vagrant实例,我假设providion.py存在问题,它实际上没有打开端口9991。您是否可以使用telnet或netcat之类的工具从vagrant机器内部访问localhost:9991?您是否有精简的/srv/zulip/provision.py文件?我不能启动一个流浪者和测试没有它。我猜端口9991被封锁,nc-z;回声$?给我1作为输出,表示端口故障
sudo netstat -lnutp