Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to open up port 8080 on my CentOS 5, Apache 2.2.3 server. When I go to ip:8080/mydirectory - it times out. I have ran these commands thus far:

$ iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
$ service iptables save
$ iptables -A OUTPUT -p tcp --dport 8080 -j ACCEPT
$ service iptables save
$ iptables -A FORWARD -p tcp --dport 8080 -j ACCEPT
$ service iptables save
$ service iptables restart
$ service httpd restart

Below is the output of my iptables

$ iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:8080

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:8080

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:8080

I edited apache to reflect this addition:

<VirtualHost *:8080>
  DocumentRoot "/var/www/html"
  ServerName dedicatedipgoeshere
</VirtualHost>

Thank you for any help!

share|improve this question
    
Are you sure you have an application that listen to 8080 in the first place? Check with 'netstat -na | grep :8080` for example, or by a telnet to localhost 8080 and see if something replies. Your default policy is ACCEPT so the additional ACCEPT policies you have added makes no difference. –  Mattias Ahnberg Jan 7 '12 at 19:15
    
Your output rule says --dport 8080. It should say --sport 8080. This is not the cause of the problem, however, as your policies are all ACCEPT anyway. –  Ladadadada Jan 8 '12 at 1:05

3 Answers 3

up vote 4 down vote accepted

You need to add Listen 8080 to your apache config. Just put it right above the VirtualHost block.

Example:

Listen 8080
<VirtualHost *:8080>
  DocumentRoot "/var/www/html"
  ServerName dedicatedipgoeshere
</VirtualHost>
share|improve this answer
    
When I restart Apache, it says this "[error] (EAI 2)Name or service not known: Could not resolve host name *.8080 -- ignoring!" –  user1062058 Jan 8 '12 at 19:04
    
*.8080 or *:8080? Must be a colon, but you have a dot in your comment. And this applies to the VirtualHost statement, the Listen directive is exactly as is in the answer. –  Patrick Jan 9 '12 at 0:04

You don't need to mess woth FORWARD and OUTPUT chain, only with INPUT.

 iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

and OUTPUT in the case if your output policy isn't ACCEPT then

 iptables -I OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

But if the upper is your iptables ruleset then the timeout isn't because of the firewall but maybe apache didn't listens to 8080. Because all of your chains has ACCEPT policy.

Try

 netstat -tpln

to check out whether apache is listening on 8080.

share|improve this answer
1  
I did all of that and ran netstat -tpln, it's not showing 8080 at all. What do you think my next step is? Thank you. –  user1062058 Jan 7 '12 at 19:15
    
You have to configure your webserver to listen on poty 8080. –  Stone Jan 7 '12 at 19:26
    
By what means do you do that, iptables? Apache? Something else? Thank you for your help. Do I set up a virtual host of *:8080 on httpd.conf? –  user1062058 Jan 7 '12 at 19:28
    
apache, see: httpd.apache.org/docs/2.2/bind.html –  Stone Jan 7 '12 at 19:30
    
I added my addition to the httpd.conf to my post at the bottom, still no luck. I couldn't figure out how to run that 'Listen' command with your link. –  user1062058 Jan 7 '12 at 19:42

As far as I remember, SELinux is enabled (and blocks) by default on CentOS. I invite you to read this wiki article for more info on SELinux (the modes in particular).

You can adjust the settings via system-config-securitylevel-tui in the CLI. A quick test of this solution would be to set SELinux to permissive and add the ports you wish to allow -- as shown in this article. I'd only recommend to disable it if you know what you are doing, specially for a production system!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.