4

I am runing a virtual box from vagrant and I am trying to access web pages that are served by guest apache server.

When I execute wget http://dev.test.com/index.html on guest everything works fine but when I execute wget http://dev.test.com:8080/index.html on host I get an error after a while:

--2013-08-09 12:04:25--  http://dev.test.com:8080/index.html
Resolving dev.test.com (dev.test.com)... 127.0.0.1
Connecting to dev.test.com (dev.test.com)|127.0.0.1|:8080... connected.
HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers.
Retrying.

I have enabled port forwarding from guest 80 to host 8080, added 127.0.0.1 dev.test.com to both guest and host /etc/hosts file and disabled guest firewall with service iptables stop but I am still getting the same error.

Can somebody tell me how to configure this correctly?

vagrant setup:

My host: Ubuntu 13.04 32bit, Vagrant 1.0.3, virtual box 4.2.10

I have set up vagnrant box like this:

vagrant box add centos64_64 http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210.box
vagrant init centos64_64
mkdir manifests
mkdir modules
cd modules

wget http://forge.puppetlabs.com/puppetlabs/apache/0.8.1.tar.gz
tar zxf 0.8.1.tar.gz
rm 0.8.1.tar.gz
mv puppetlabs-apache-0.8.1 apache

wget http://forge.puppetlabs.com/puppetlabs/stdlib/4.1.0.tar.gz
tar zxf 4.1.0.tar.gz
rm 4.1.0.tar.gz
mv puppetlabs-stdlib-4.1.0 stdlib

wget https://forge.puppetlabs.com/ripienaar/concat/0.2.0.tar.gz
tar zxf 0.2.0.tar.gz
rm 0.2.0.tar.gz
mv ripienaar-concat-0.2.0 concat

changed Vagrantfile content to:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant::Config.run do |config|
  config.vm.box = "centos64_64"

  config.vm.provision :puppet do |puppet|
    puppet.manifests_path = "manifests"
    puppet.manifest_file = "setup.pp"
    puppet.module_path = "modules"
  end

  config.vm.forward_port 80, 8080
end

and created setup.pp file with this content:

class{ "apache": }

apache::vhost { 'dev.test.com':
  port    => '80',
  docroot => '/var/www/html/test.com',
}

EDIT

netstat -tnl

guest:

tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:3306              0.0.0.0:*                   LISTEN      
tcp        0      0 :::80                       :::*                        LISTEN      
tcp        0      0 :::22                       :::*                        LISTEN      
tcp        0      0 ::1:25                      :::*                        LISTEN      
tcp        0      0 :::443                      :::*                        LISTEN

host:

tcp        0      0 0.0.0.0:993             0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:995             0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:2222            0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:110             0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:143             0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:4190            0.0.0.0:*               LISTEN     
tcp6       0      0 :::993                  :::*                    LISTEN     
tcp6       0      0 :::995                  :::*                    LISTEN     
tcp6       0      0 :::110                  :::*                    LISTEN     
tcp6       0      0 :::143                  :::*                    LISTEN     
tcp6       0      0 :::80                   :::*                    LISTEN     
tcp6       0      0 ::1:631                 :::*                    LISTEN     
tcp6       0      0 :::25                   :::*                    LISTEN     
tcp6       0      0 :::4190                 :::*                    LISTEN

EDIT 2

The problem seems to be related to CentOS 6.3/6.4 64bit guest machines. I tried a few of them and the forwarding did not work. Now I tried CentOS 5.9 64bit (http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210.box) with same puppet scripts and port forwarding works.

Here is netstat -tnl output for this guest:

tcp        0      0 0.0.0.0:808                 0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:3306              0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      
tcp        0      0 :::80                       :::*                        LISTEN      
tcp        0      0 :::22                       :::*                        LISTEN      
tcp        0      0 :::443                      :::*                        LISTEN

I will stick with the older version for now but am still interested in reason why it does not work with newer versions.

3
  • What if you execute wget http://localhost:8080/index.html? Please post your netstat -tnl Aug 9, 2013 at 11:32
  • I get the same problem with localhost. Have added netstat -tnl result to my question. Aug 9, 2013 at 11:55
  • What's the IP address of your host, and your vagrant box, and what kind of networking in Virtualbox is it using? Aug 9, 2013 at 12:18

0

You must log in to answer this question.

Browse other questions tagged .