webdevRefinery Forum: Can't access Apache in my CentOS Virtualbox - webdevRefinery Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Rate Topic: -----

User is offline timtamboy63 

  • Group: Members
  • Posts: 8
  • Joined: 16-January 12

Posted 27 January 2012 - 10:47 PM (#1)

Can't access Apache in my CentOS Virtualbox


I'm setting up a VirtualBox with CentOS so I can test out all my code, etc. on a Linux box instead of the Windows I use for development.

I just got the SSH working (I SSH to localhost:2222 and it port forwards it to the virtualbox port 22).

It's using NAT because for some reason it refuses to start with a bridged adapter.

I'm trying to do the same thing with Apache, to get a web server up and running.

I've portforwarded port 8888 on localhost to port 80 in my CentOS Virtualbox, but I can't seem to access anything with localhost:8888 in my browser?

Apache is also definitely running:

ps -e | grep httpd
2108  ?      00:00:00 httpd
2110  ?      00:00:00 httpd
2111  ?      00:00:00 httpd
2112  ?      00:00:00 httpd
2113  ?      00:00:00 httpd
2114  ?      00:00:00 httpd
2115  ?      00:00:00 httpd
2116  ?      00:00:00 httpd
2117  ?      00:00:00 httpd


Iptables:
# Generated by iptables-save v1.4.7 on Fri Jan 27 18:26:36 2012
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [32:2278]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
-I INPUT -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
_I OUTPUT -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
-I INPUT -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
-I OUTPUT -p tcp --sport 443 -m state --state ESTABLISHED -j ACCEPT
COMMIT
# Completed on Fri Jan 27 18:26:36 2012


've also stopped iptables, so that's not interfering. I tried to telnet into port 80 from my CentOS Virtualmachine to see if it'd work, and Neither 127.0.0.1 or [vm ip] works for telneting to port 80. It gets to connecting to [ip] and then says connection closed by foreign host. For the listen lines in my httpd.conf, it says listen 80

nmap output
[root@CentOS conf]# nmap localhost

Starting Nmap 5.21 ( http://nmap.org ) at 2012-01-28 00:58 WST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.0000090s latency).
Hostname localhost resolves to 3 IPs. Only scanned 127.0.0.1
Not shown: 993 closed ports
PORT    STATE SERVICE
22/tcp  open  ssh
23/tcp  open  telnet
25/tcp  open  smtp
80/tcp  open  http
111/tcp open  rpcbind
443/tcp open  https
631/tcp open  ipp


When I try wgeting the default apache page:
[root@CentOS web]# wget 15.0.2.15/index.html
--2012-01-28 01:03:51--  http://15.0.2.15/index.html
Connecting to 15.0.2.15:80... failed: Connection timed out.
Retrying.


EDIT: When I wget the apache start page using localhost instead of 15.0.2.15, it works fine?

EDIT:
[root@CentOS /]# netstat -tlnp | grep http
tcp        0      0 :::80                       0.0.0.0:*                        LISTEN      2032/httpd
tcp        0      0 :::443                      :::*                        LISTEN      2032/httpd

I've been at it for a day or two, and it's really bugging me! Any help would be greatly appreciated, cheers!
0


User is offline Ruku 

  • I do Linux and that Internet thing.
  • Group: Members
  • Posts: 1349
  • Joined: 17-April 10
  • Location/root
  • Expertise:HTML,CSS,PHP,Javascript,Python,SQL

Posted 29 January 2012 - 07:24 AM (#2)

To clarify, when you're logged in to the VM in VirtualBox and you do the following:

curl -I http://localhost/


What output do you get?
0


User is offline timtamboy63 

  • Group: Members
  • Posts: 8
  • Joined: 16-January 12

Posted 01 February 2012 - 10:11 AM (#3)

Hey,

Here's what I get:

[root@CentOS web]# curl -I http://localhost/
HTTP/1.1 200 OK
Date: Sat, 28 Jan 2012 00:03:39 GMT
Server: Apache/2.2.15 (CentOS)
Last-Modified: Fri, 27 Jan 2012 18:44:52 GMT
ETag: "2721-23-4b786e4703702"
Accept-Ranges: bytes
Content-Length: 35
Connection: close
Content-Type: text/html; charset=UTF-8


0


User is offline Ruku 

  • I do Linux and that Internet thing.
  • Group: Members
  • Posts: 1349
  • Joined: 17-April 10
  • Location/root
  • Expertise:HTML,CSS,PHP,Javascript,Python,SQL

Posted 01 February 2012 - 02:45 PM (#4)

I think you may be using a slightly wonky VirtualBox networking setup, but we can fix it fairly easily. Your web server works perfectly on the VM, as evidenced by the
200 OK
response :D

The easiest way is for you shut down the virtual machine you're using (shut it down properly, because VirtualBox prevents you from changing certain settings while the VM is running), right-click the VM you're working with and choose settings. Choose network from the frame on the left, and on the first adapter tab, make sure it's enabled and set its type to bridged. Make sure you pick the right device to bridge it to, too (pick the device you'rte connected to the Internet with at that time). When you boot up the VM and do
ifconfig | grep 'inet addr'
, you should get an IP that's in a similar range to your physical PC's (usually
192.168.x.x
).

If you don't want to do this, you can bridge the VirtualBox virtual network adapter on your host to your machine's LAN port, but this is more advanced and likely not necessary for what you're doing :)
0


User is offline timtamboy63 

  • Group: Members
  • Posts: 8
  • Joined: 16-January 12

Posted 10 February 2012 - 09:45 PM (#5)

Hey Ruku,

I've tried this, and for some reason it refuses to start up when I set it to bridged, here's what it says:
Failed to open a session for the virtual machine CentOS Server. Unknown configuration node '//ssh' found in the configuration of IntNet instance #0 (VERR_CFGM_CONFIG_UNKNOWN_NODE).

0


User is offline Ruku 

  • I do Linux and that Internet thing.
  • Group: Members
  • Posts: 1349
  • Joined: 17-April 10
  • Location/root
  • Expertise:HTML,CSS,PHP,Javascript,Python,SQL

Posted 11 February 2012 - 09:47 AM (#6)

View Posttimtamboy63, on 10 February 2012 - 09:45 PM, said:

Hey Ruku,

I've tried this, and for some reason it refuses to start up when I set it to bridged, here's what it says:
Failed to open a session for the virtual machine CentOS Server. Unknown configuration node '//ssh' found in the configuration of IntNet instance #0 (VERR_CFGM_CONFIG_UNKNOWN_NODE).



Try creating a new VM using the same disk images; it sounds like you have some extradata entries in the machine's configuration that are invalid with VirtualBox 4.x. Alternatively, search the .xml file for the VM for 'ssh' (or post it here; it should be somewhere in the VirtualBox VMs folder of your profile).
0


User is offline timtamboy63 

  • Group: Members
  • Posts: 8
  • Joined: 16-January 12

Posted 11 February 2012 - 10:40 PM (#7)

Where would I find the .xml file? I looked before, but I couldn't find it.

Found it:
      <ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" value="22"/>
      <ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" value="2222"/>
      <ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" value="TCP"/>


EDIT:
Removed those nodes, and everything instantly started working, thanks so much!
0


User is offline Ruku 

  • I do Linux and that Internet thing.
  • Group: Members
  • Posts: 1349
  • Joined: 17-April 10
  • Location/root
  • Expertise:HTML,CSS,PHP,Javascript,Python,SQL

Posted 12 February 2012 - 06:17 PM (#8)

Glad it works :)

I'd consider that a bug in VirtualBox, though: it should provide a means of removing these troublesome attributes, especially as it left them there on the first place. :s
0


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

3 User(s) are reading this topic
0 members, 3 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services