2013-04-11 81 views
5

我试图在我的开发环境中安装Jenkins on Vagrant。Jenkins安装在Vagrant之后,无法从浏览器连接

我为我的盒子选择Ubuntu http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-amd64-disk1.box。这是我用来提供箱子的外壳。一切都很顺利,但是当我尝试从端口80或甚至8080访问该框时,它只是没有响应。浏览只是保持旋转。不知道我在这里做错了什么。

这是我的脚本。

 

sudo apt-get update 

echo "APT::Cache-Limit "100000000";" >> /etc/apt/apt.conf.d/70debconf 

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add - 
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list' 

sudo apt-get -y --force-yes install jenkins 

sudo apt-get -y --force-yes install apache2 
sudo a2enmod proxy 
sudo a2enmod proxy_http 
sudo a2enmod vhost_alias 
sudo a2dissite default 

echo ' 
     ServerAdmin [email protected] 
     ServerName ci.company.com 
     ServerAlias ci 
     ProxyRequests Off 
     
       Order deny,allow 
       Allow from all 
     
     ProxyPreserveHost on 
     ProxyPass/http://localhost:8080/ 
' >> /etc/apache2/sites-available/jenkins 

sudo a2ensite jenkins 
sudo sh -c 'echo "ServerName localhost" >> /etc/apache2/conf.d/name' && sudo service apache2 restart 
sudo apache2ctl restart 
 

而且我vagrant ssh和运行

curl 'http://localhost:8080' 

,并返回詹金斯页面,所以我认为詹金斯启动并正常运行。我无法从外面访问它。

这里是我的Vagrantfile

 

Vagrant.configure("2") do |config| 
    config.vm.provision :shell, :path => "install-jenkins.sh" 
    config.vm.provider "virtualbox" do |v| 
    v.customize ["modifyvm", :id, "--memory", "2024"] 
    end 

    # Every Vagrant virtual environment requires a box to build off of. 
    config.vm.box = "ubuntu64" 

    # 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. 
    config.vm.network :forwarded_port, guest: 80, host: 8080 
end 
 
+1

标准问题:是否有某种防火墙的参与? – cmur2 2013-04-11 10:01:19

+0

但从我的理解空的Ubuntu没有任何防火墙了吗?或者我错了? – toy 2013-04-11 10:56:38

+0

也许,我不知道你的特定盒子的内部 - 是你的虚拟机上的端口80上的Jenkins监听,我有一些模糊的想法,默认情况下它可能在端口8080上侦听? – cmur2 2013-04-11 11:31:02

回答

2

我做了这个工作,通过提供IP,以这样的流浪框:

config.vm.network :hostonly, "33.33.33.10" 
+1

你能解释一下吗?因为它不适合我,再加上我认为它不是主机,而是私人网络 – julestruong 2016-02-01 13:19:05

相关问题