3

I have VirtualBox 4.3.12 with Fedora 20 and nginx 1.4.7 installed. Machine has Bridged Network interface and pings can be done both ways: from host machine (Windows 7) using

ping 192.168.0.15 (virtual machine's ip address)

and from guest machine

ping 192.168.0.10 (host machine ip address)

but what i can't do is access guest machine's nginx from host machine. I have read this and this and have done as those articles / previously asked question told me to, but i still can't manage to view nginx site from host machine.

netstat -tnlp returns:

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN        930/nginx: master p 
Marcin
  • 33
  • Firewall allowing port 80 access to guest's IP? – slm Nov 21 '14 at 01:49
  • Does Virtualbox reserve port 80 for anything? – Suchipi Nov 21 '14 at 06:21
  • Yes, firewall on Windows was allowing port 80 to access guest's IP. And @Suchipi: it didn't, but it is working now, i had to add new entry to iptables: iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT, and it is all working now, thank you guys! – Marcin Nov 21 '14 at 14:08
  • Did you figure this out? – Nate Oct 19 '15 at 17:00
  • Yes, @Nate, All i had to do was: iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT in VM's console. – Marcin Nov 16 '15 at 20:08
  • didn't work for me :( (also you should make it an answer if it worked for you) – Assimilater Sep 15 '16 at 21:40

2 Answers2

2

When I did:

iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT

I got an error of:

iptables: Index of insertion too big.

The reason is that I do not have any policies in place and so the "INPUT 4" part is trying to insert at index 4 when it should be index = 1. To view your rules do:

sudo iptables --list-rules

Then insert at the appropriate index. (In most cases):

sudo iptables -I INPUT 1 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT

This finally got it to work!

  • My virtualbox settings are:

    • host port 8080,
    • guest IP 10.0.2.15
    • guest port 80

nginx conf file is:

server {
  listen 0.0.0.0:80;

  location / {
      proxy_pass http://localhost:9000;
      }
}
0

I did:

iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT

in VM's console and it worked.

Marcin
  • 33