LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   port forwarding for apache (https://www.linuxquestions.org/questions/linux-newbie-8/port-forwarding-for-apache-4175450473/)

iceman81 02-16-2013 05:59 PM

port forwarding for apache
 
i just set up an apache server, and after it was all said and done i find out my isp blocks port 80 and 8080. i am using no-ip.org to redirect to port 8181. however i can't get apache to accept "listen" on any ports other than 80 and 8080. so my question is, can i forward the port in my router to come in at 8181 and switch to 80 to the linux box ip (192.168.1.7) or should i just forward 8181 to it and redirect it in my firewall or through some other method like tomcat ex:

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

also if i do a netstat it doesn't show that i am actively listening on that port(8181) so i guess i would have to open it up somehow...

it seems like i am almost there, i just need alittle nudge to get me over the hill.

ps, i'm getting the error "can't bind 8181 no listening sockets available

joecam1673 02-16-2013 08:27 PM

Well, you could go about this a number of ways. Your router might be an option. Generally they'll allow public and private ports. In that instance you could set the public port to 8181(or whatever you want) and your private port to 80 and leave your internal config the way it is.

Changing the listening port on apache is easily done by editing your ports.conf file. Where that is depends on what version of apache and/or what distro you're running but either /etc/apache2 or /etc/httpd are pretty safe bets.

"Listening 80" would be changed to "Listening 8181" and then reloading apache "/etc/init.d/apache2 reload" or "/etc/init.d/httpd reload" will load your config changes.

A quick "netstat -napt | egrep -i 'apache|http'" should reveal your listening on the new port.

Hope that helps.

iceman81 02-16-2013 08:52 PM

I did not realize in the port forwarding section of my router that there was a check box to allow internal and external port to be different. Works like a charm now. Although i was not aware of the ports.conf i was only editing httpd.conf. thanks for the response :)

joecam1673 02-17-2013 03:18 AM

Happy to help.


All times are GMT -5. The time now is 02:08 AM.