Objective To be able to connect to httpd running inside a guest from other machines on the same LAN as the host.
Approach taken I have configured a NAT interface with port forwarding on the guest. The host machine's port 8080 is being forwarded to the guest machines port 80.
The guest also has a host-only interface, this is used only to check if httpd's status (running/stopped) from the host.
I have the following setup:
- Host --> Fedora
- Guest --> Debian 9
- Network interfaces (2)
- Host Only
- Port forwarding Host Port 8080 forwarded to Guest Port 80
Issue I am unable to access port 80 on the guest from the host (by using localhost:8080, i.e., without using the host-only interface), consequently, it is accessible from LAN either.
That said, i also have ssh on the guest, I tried the same port forwarding setup for ssh,i.e, forward Host:8080 to Guest:22 and it worked! I can SSH into the guest from the Host and also from other machines on the same LAN. So it doesn't seem to be a firewall issue.
I have got httpd listening on 0.0.0.0:80 via /etc/apache2/ports.conf. I have also tried changing the port httpd listens on without much luck.Similarly, I have also tried specifying the IP Address httpd listens to as the IP Assigned by VirtualBox to the NAT interface without much lick either.
I have tried creating a new NAT interface from File>Preference>Network and also by adding port forwarding to the default NAT interface built into VirtualBox.
Running a wget on the host gives the following output
# wget localhost:8080 --2017-08-08 13:06:33-- http://localhost:8080/ Resolving localhost (localhost)... ::1, 127.0.0.1 Connecting to localhost (localhost)|::1|:8080... failed: Connection refused. Connecting to localhost (localhost)|127.0.0.1|:8080... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://localhost/ [following] --2017-08-08 13:06:34-- http://localhost/ Connecting to localhost (localhost)|127.0.0.1|:80... failed: Connection refused. Resolving localhost (localhost)... ::1, 127.0.0.1 Connecting to localhost (localhost)|::1|:80... failed: Connection refused. Connecting to localhost (localhost)|127.0.0.1|:80... failed: Connection refused.
The excerpts of the output produced by the netstat command on the Host and Guest are Host machine:
Local Address Foreign Address State 192.168.1.2:8080 192.168.1.2:52162 FIN_WAIT2
Local Address Foreign Address State 10.0.2.15:80 10.0.2.2:52162 FIN_WAIT2
So the connection is being forwarded to the guest? There is no firewall on the guest (iptables -L returns an empty list). SSH being accessible while httpd not being accessible probably means it is a httpd configuration issue?
What could i possibly be missing here?