-1

Hi I am trying to reach my centos Virtual machine which i created inside in a VMware vcenter using http://server-IP/ but couldn't have access using http. but i can access it using ssh. in the httpd.conf file i tried to change

"Listen 80" to Listen 8080 in the iptables also i have added the rule

**"-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT"**

But i still couldn't access it in my internet browser. need help to fix this . Thanks

Dave
  • 1
  • 1

3 Answers3

0

Which version on CentOS exactly ?

What you could try, temporarily, is to disable iptables/firewalld (depending on your version), and see if you can access your website. If you can't, then at least you know it's not a firewall problem.

Eihwaz
  • 1
  • 3
  • Actually it worked when I stopped the iptables and can access my vm using http://server-ip:8060/. But i need the iptables rule to work as i will be using this centos 6.5 vm for nagios server. – Dave Sep 07 '15 at 08:18
0

What is the port your apache listening, 80 or 8080? If you want to redirect 8080 to 80, use the following rule:

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

that will redirect all the traffic from 8080 to 80.

Can you run netstat -nltp and put here the output?

Stas
  • 166
  • 1
  • 3
0

Try this:

iptables -A INPUT -p tcp --dport 8080 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 8080 -m state --state ESTABLISHED -j ACCEPT

Also make sure that the order of the rules is the right one. Sometimes there is a more restrictive rule after your rules.

Jorge Martinez
  • 1,221
  • 8
  • 16
  • this was the default rule : *filter **:INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited** – Dave Sep 07 '15 at 09:51