Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Basically, when I was at school I used apache to have a webserver, and I only really used it so I could listen to music at work and stuff. Now I'm at home and behind a router, and when I turn on apache and go to my IP it doesn't connect. I read some other posts, and I ended up going to 127.x.x or whatever that number is. Site came up. Now how do I get it to work for outsiders?
The reason you can't connect to your own IP (Your public IP given to you by your ISP, which in this case will be given to the router) is because your router is doing NAT (Network Address Translation), which means it acts as the computer that is directly connected to the Internet, and 'shields' you off by creating a network of the machines you connect to it, yet allows you to have direct access to the internet from any machine connected to the router. Trying to go in from the 'outside' with your networked machines (by using your public IP) won't work, because the IP is outside your own network, and since your router doesn't run those services.. (Apache in this case) you'll find yourself staring into a black hole.
127.0.0.1 is the internal 'loopback' address of your own computer, it is a reserved address that exists on every computer. Using that address, you can connect directly to your own machine with a browser or somesuch if you are running a service such as Apache. However, 127.0.0.1 can not be used to refer to a machine on the internet, because it refers to the machine the request is sent from (Internal loopback).
To make machines outside your own network (from the Internet) able to access a machine inside your network, you need to set up port forwarding on your router.
Your Apache server will need a static IP address such as 192.168.0.1 (If you want to keep things simpler, for instance if you use DHCP to configure your Apache server's IP address, and you reboot it and it changes, you'll be forced to change the IP that your router uses to forward port 80 to.), and you'll need to set up your router to forward port 80 to your Apache server on that IP. That way, on the outside (The Internet) port 80 will become publicly available through your public IP, and any request sent to that port will be forwarded to your Apache server, by the router.
Have a look in your router's manual for specific instructions on how to set up port forwarding.
Well, I gave it a shot and couldn't find anything on the router's software (it's microsoft base) that lets me forward to any ports. Am I going about this the wrong way?
It's a bit old thread, but fyi, i'm facing the exact same problem with you, and the only way i've found in order to make apache2 visible from outside is to add to /etc/hosts the fqdn of my dyndns.org account as an alias to the computer's hostname...
Can you try this and see if it works? On the other hand, i'm not sure if this kind of setup is a good one (i believe there has to be something on apache's conf in order to automatically accept requests for my dyndns name and not to have to add it to hosts...)
Originally posted by or1onas It's a bit old thread, but fyi, i'm facing the exact same problem with you, and the only way i've found in order to make apache2 visible from outside is to add to /etc/hosts the fqdn of my dyndns.org account as an alias to the computer's hostname...
Can you try this and see if it works? On the other hand, i'm not sure if this kind of setup is a good one (i believe there has to be something on apache's conf in order to automatically accept requests for my dyndns name and not to have to add it to hosts...)
that seems a bit odd to me, but what do i know? have you tried to access the site on other computers outside your network and not just your own? it seems to me that resolving your dyndns.org account to localhost will just tell your local machine to do that. iow, when you are at your computer and you enter the dyndns.org address, /etc/hosts tells it to go to localhost, and so it just loops back to your own machine. you aren't really going out to the web at all, but just back to your own server. and as you might guess by now, that also won't affect computers other than the one on which you changed the /etc/hosts.
as Xolo already described, for other people to connect to you, you need to forward the http port (usually 80) on your router so that computers on the "other side" of the router can get through it to access your web server. that should be fairly easy to do if you look around in your router's configuration options. or else post what kind of router you have and someone will try to give more specific instructions.
Last edited by synaptical; 07-17-2005 at 09:34 AM.
Port-forwarding is certainly already set up on the router (zyxel 650R-31).
You're right though about hosts, it's not working...
I'm really stuck on this, any other ideas? Is there something i need to change in apache conf?
Originally posted by or1onas Port-forwarding is certainly already set up on the router (zyxel 650R-31).
You're right though about hosts, it's not working...
I'm really stuck on this, any other ideas? Is there something i need to change in apache conf?
i guess the original thread is old enough that we can slightly "hijack" it here. it's about the same subject anyway, so it could help with the OP's problem. if it's not appropriate, one of the mods will probably let us know.
if you can connect to the server at all, that would seem to indicate the apache configuration is good. i would guess the problem is somewhere else, e.g., the dyndns configuration (can you post that info? in general terms if you want, etc.), or the router. are you absolutely sure the router is configured to allow port 80? some screen shots might help in case you have any doubts that it's set correctly.
just to be sure, however, it probably wouldn't hurt to post the first parts of your httpd.conf file, the global part and the first part of main, or whatever they call it. i.e., down to about right under where your first <Directory> "allow override," etc. options are. you can leave out all that stuff after that that you probably didn't mess with (unless you did mess with it, then post it. )
I'm working on ubuntu 5.04. The apache2 file structure is a bit different than of other distros.
apache2.conf shows the following (i've got them altogether):
AccessFileName .htaccess
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>
HostnameLookups Off
UseCanonicalName Off
DocumentRoot "/var/www/"
<Directory />
Options FollowSymLinks -Indexes
AllowOverride None
</Directory>
<Directory /var/www/photos/eb2005>
Options -Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
It's working perfectly from LAN. Could there be something related to iptables maybe?
It's my first time trying to set up apache and i'm a bit of a newbie in general...
Oh, and thanx for helping me ;-)
oh you have iptables? In that case, post the http part of your iptables script. i only know basic iptables stuff, but if it's anything more complicated a guru might chime in.
Last edited by synaptical; 07-17-2005 at 10:46 AM.
i think that just says you have no user rules yet.
go to /etc/init.d and find your iptables script (hopefully it will be called iptables), and search through it for anything that says http. you should have a line in there somewhere that says:
if it's commented (has # in front of it), that's your problem. remove the comment mark and restart the service:
./iptables restart
then test your server again.
there might even be a gui way to do that depending on what desktop you use, but you might as well just go right to the source.
hopefully that's it, but as i said, i'm not an iptables guru by any means.
>> p.s. if your script has a different format and it's not as easy as just uncommenting something, post the http part so someone can take a look at it for you. or else i'll give you the script i use on my debian box, which works and allows http. it's also very simple and easy to modify/edit, you could use that instead.
Last edited by synaptical; 07-17-2005 at 11:05 AM.
/etc/init.d does not have an iptables script.
i just found this link: http://ubuntuforums.org/showthread.php?t=31663
which says that the default ubuntu installation comes with iptables open to anything in/out. So i guess this should not be the prob.
Could there be any other service besides iptables which could create this problem?
Originally posted by or1onas I'll let u know when you're back online cause it's a dynamic one (of course), but could this be of any help?
if it's dynamic that's most likely your problem if you're not changing it each time in dyndns.com. you can always check your current IP at whatismyip.com to verify it's what you have in dyndns.
are you sure that your ISP allows port 80? some don't, you know, making you have to change it to something else (8080, etc.). then you just append the port number to the end of your urls with a colon, e.g., http://my.domain.com:8080
>>edit: i just looked at the dyndns site, and they have third-party linux tools to automatically update for dynamic dns. you might want to check them out if that's the problem: https://www.dyndns.com/support/clients/
Last edited by synaptical; 07-17-2005 at 05:13 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.