I'm trying to install Jenkins on Vagrant for my development environment.
I choose Ubuntu http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-amd64-disk1.box for my box. And this is the shell that I use to provision my box up. Everything went ok, but when I tried accessing the box from port 80 or even :8080 it's just not responding. The browsing just kept spinning. Not sure what I did wrong here.
Here's my script.
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 webmaster@localhost
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
Also I vagrant ssh
and run
curl 'http://localhost:8080'
and it returned the Jenkins page, so I think Jenkins is up and running properly. I just couldn't access it from outside.
Here's my 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
I made this work by providing an IP to the Vagrant box like this:
config.vm.network :hostonly, "33.33.33.10"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With