LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Setup home web server to public (http://www.linuxquestions.org/questions/linux-general-1/setup-home-web-server-to-public-906582/)

nuttynibbles 10-05-2011 11:20 AM

Setup home web server to public
 
I've setup my home desktop as a webserver (For testing purpose). I've opened up to the public by configuring port forward in my router. I checked with my friends and realised some of them couldn't access it. At first I thought the nameserver haven't propagate my domain info to the world. But now I realise that my ISP block port 80. Strange thing is some of my friends and I were able to access it.

Anyway, I wanna change the port number from 80 to 8140. So i opened up httpd.conf, and changed to 'Listen 8140' and in the virtualhost settings I set it to:

Code:

<VirtualHost *:8140>
ServerName example.com
DocumentRoot /var/www/html/example
RewriteEngine On
</VirtualHost>

Initially while changing the port number, i encountered this error when restarting httpd:

Code:

Permission denied: make_sock: could not bind to address [::]:8140
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:8140
no listening sockets available, shutting down
Unable to open logs

So I keyed in the following commands in the terminal and it works:

Code:

semanage port -a -t http_port_t -p tcp 8140
service httpd start

In my linksys router config, I went to Applications and Gaming > Port Range Forward and key in the following info for port forwarding:

Code:

Application | Start | End | Protocol | IP Address | Enabled
Example | 8140 | 8140 | TCP | 192.168.1.102 | Checkbox checked

I restarted apache a few times and I still can't access my web example.com:8140 on the browser. However, I was able to access it locally on the webserver with 127.0.0.1:8140

In my nameserver settings, I've set my A records to be:

Code:

Name | IP
example.com. | 112.8.8.1

Where did I go wrong??

kbp 10-05-2011 06:38 PM

Check to ensure apache (httpd) is listening on all interfaces not just localhost - 'netstat -tnlp' as root

nuttynibbles 10-06-2011 09:29 AM

hi,

yup httpd is listening to all port. i did netstat -tnlp and i get:
tcp 0 :::80 :::* LISTEN 8706/httpd

do i need to key in the port number for the A records?

kbp 10-06-2011 05:53 PM

No, A records do not include port information. Do you have another machine on the same network that you can use to test access to the site? ... this will rule out the host as the problem source.

nuttynibbles 10-06-2011 07:05 PM

yup i got another computer actually. two comps actually =D. but i cannot access example.com:8140 and with the local ip 192.168.1.102:8140 but i can ping 192.168.1.102. but as mentioned, i was able to go to 127.0.0.1:8140 on the host machine itself

bret381 10-06-2011 07:25 PM

I know this may be a dumb question, but is your servers ip address 192.168.1.102? If it's not set as a static ip. The other computer may have taken that IP from it giving you an unaccessible webserver.

nuttynibbles 10-06-2011 07:42 PM

hi bret381, lol it's not a dumb Q.

anw 192.168.1.102 is the local address in my network. My other computers are 192.168.1.101 and etc. My public ip is dynamic though. but from the router administration status, i could see it didn't change for the past 2 weeks.

To make things more complicated, if i change the port back to 80, i'm able to access example.com from my other computer. however, most friends outside my network cannot access except for 1 which im not sure why. so i suppose my isp block port 80

Q is should I able to access the web server within the local network with 192.168.1.102:8140 from my other computer @ 192.168.1.101??

kbp 10-06-2011 08:00 PM

Quote:

should I able to access the web server within the local network with 192.168.1.102:8140 from my other computer @ 192.168.1.101??
.. you'll probably need to add an entry to <windir>\system32\drivers\etc\hosts on 192.168.1.101:
Code:

192.168.1.102  example.com

frankbell 10-06-2011 09:54 PM

Quote:

Originally Posted by nuttynibbles (Post 4491995)
To make things more complicated, if i change the port back to 80, i'm able to access example.com from my other computer. however, most friends outside my network cannot access except for 1 which im not sure why. so i suppose my isp block port 80

Q is should I able to access the web server within the local network with 192.168.1.102:8140 from my other computer @ 192.168.1.101??

Is port 8140 open in your router and set to forward to the correct machine?

nuttynibbles 10-07-2011 11:24 AM

hi frankbell, yes i suppose i did open my port and allow port forwarding on 8140 correctly. i followed the steps for router settings @ http://versatile1.wordpress.com/2007...-for-utorrent/ but im using a dhcp for dynamic ip allocation for computers on my network. i guess that is fine as long my local ip dont change and it hasn't change since.

nuttynibbles 10-07-2011 11:53 AM

okay i cleared my iptables and now it works.

i noe this is not a solution but im wondering what could be wrong with my settings. is there a way to check what were the settings i've cleared??

nuttynibbles 10-07-2011 12:48 PM

what i did is openup iptables and added accept port 81. restart iptables and it works

frankbell 10-07-2011 07:58 PM

I would suggest that you mark this thread as solved, so that others who might have similar problems can learn from it. And congrats.


All times are GMT -5. The time now is 11:52 PM.