Other people cannot access my localhost
Posted by: names_are_useless (---.washdc.fios.verizon.net)
Date: March 05, 2013 03:23AM

Hello WampServer Forums,

This is the first time in my life that I've tried to host a website online, and I'm definitely a networking newb, so please be easy on me smiling smiley

Recently I downloaded MediaWiki and have created a basic wiki for a game project I'm working on. All I want to do right now is show a few people my localhost, which contains my mock-up Wiki (its a temporary home until I find a server host). I have also installed WAMP since I've heard good things about it (I'm on a Windows 7 machine btw).

Unfortunately, only my local computer can access my localhost. On my local computer, when I type in http://[local IPv4 address]/, the address bar changes to http://localhost/index.php/Main_Page and the webpage come up) On the other computers in my home however, when I type in the http://[local IPv4 address]/ of the computer that I've created the wiki, the address bar changes to http://localhost/index.php/Main_Page and I receive the message "Unable to connect" (before I enabled Firewall port 80, it wouldn't even show the filepath of my localhost in the address bar, so I figure I've done something right).

Here is what I've done so far:
* Created a basic MediaWiki page (localhost accessible on local computer)
* WAMP Server is online
* TCP Port 80 (Private and Public) is checked under Control Panel\System and Security\Windows Firewall\Allowed Programs
* WAMP (Private and Public) is checked under Control Panel\System and Security\Windows Firewall\Allowed Programs
* Created Windows Firewall Inbound Rule TCP Port 80 (which allows all connections, Local & Remote Ports: All Ports, Applies to Domain/Public/Private)
* Created Windows Firewall Outbound Rule TCP Port 80 (which allows all connections, Local & Remote Ports: All Ports, Applies to Domain/Public/Private)

Perhaps I went a bit overboard on the Firewall exceptions? Anyways, I'm stumped on what to do next. Any advice on how other computers in my home can look at my localhost? I suppose then the followup question will be what I have to do so others on the Internet can look at my localhost?

Options: ReplyQuote
Re: Other people cannot access my localhost
Posted by: RiggsFolly (---.as13285.net)
Date: March 05, 2013 02:56PM

Hi,

Right the simple answer is wamp is configured, by default, for local development, to keep those new to Apache and MySQL safe from attack.

So its security is set to only allow access to Apache from the localhost address ( 127.0.0.1 ).

Now if you want to allow other PC's in your home network to see the website you have developed you need to change that security a little so that Apache will accept access attempts from then. Currently it is just rejecting any communication from any IP address other than 127.0.0.1.

The simple method to open up Apache is to use the wamp manager icon in the system tray.
left click on it and select the 'Put Online' option.


This will tell Apache to respond to any ip address in the universe, and server pages for their requests.


A more secure method would be to edit the httpd.conf file ( using the wampmanager menu system ) and make a small change to the security in there so only the ip addresses in your local home network will be allowed into Apache

To do this find this section of the httpd.conf file

<Directory "d:/wamp/www/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# [httpd.apache.org]
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride all

#
# Controls who can get stuff from this server.
#

# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 ::1 192.168.2

</Directory>

And add one more line like this

<Directory "d:/wamp/www/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# [httpd.apache.org]
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride all

#
# Controls who can get stuff from this server.
#

# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from 192.168.1
</Directory>

Note that this should be the subnet that your router allocates and only the first 3 of the quartets.
So lets say that one of the pcs on your internal network has ip address 192.168.1.10, then the first 3 quartets are 192.168.1
This will have the effect of allowing any PC/Device connected to your internal network to talk to apache.


Find out your subnet ( if you dont already know ) by doing
>ipconfig
from a dos box and looking at the 'IPv4 Address'

Options: ReplyQuote
Re: Other people cannot access my localhost
Posted by: names_are_useless (---.washdc.fios.verizon.net)
Date: March 06, 2013 02:45AM

Thank you for the response RiggsFolly smiling smiley

I already know how to "Put Online": the problem was that even with it set online, other computers on my local network could not access the page.

Well, thankfully that problem is over: I found out that, in httpd.conf, I had "Listen 80", but it was not pointing to my local IP. So I changed it to "Listen 192.168.1.5:80" and put in the address path http://192.168.1.5/index.php/Main_Page (just putting in http://192.168.1.5 would not load the page) and viola! Now all my computers on my network can access the page smiling smiley (formatting is a bit messed up instead of via localhost, but that's a MediaWiki question tongue sticking out smiley)

(I've also learned that I need to reset the Listen parameter to 80 in httpd.conf in order to access localhost directly on my main machine)

So now that that's done, I am curious what I'd need to do next in order to get my website on the Internet now? I'm assuming I'd need to allow my local IP address through my router? What security parameters should I take when doing so? And should I still set up httpd.conf the way you suggested RiggsFolly?

If I still should, I'm a bit confused as to your explanation. So do I need to have two <Directory> tags? Or could I put all the settings you mentioned in only 1 <Directory> tag (just before the </Directory>winking smiley?

<Directory "c:/wamp/www/">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # [httpd.apache.org]
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #

#   onlineoffline tag - don't remove
    Order Allow,Deny
    Deny from all
    Allow from 127.0.0.1 ::1 192.168.2
    Allow from 192.168.1 

</Directory>
(like so?)



Edited 1 time(s). Last edit at 03/06/2013 02:47AM by names_are_useless.

Options: ReplyQuote
Re: Other people cannot access my localhost
Posted by: RiggsFolly (---.as13285.net)
Date: March 06, 2013 10:31AM

RE: My confusing explanation

You only need the one section, just add the extra line to it i.e. add
Allow from 192.168.1
below the existing line Allow from 127.0.0.1



Right, so adding the ip address in front of the Listen command is not recomended, especially if you have not made that PC use a static ip ( ip address allocated by router dhcp will not always be the same ). However it does point to the root of the problem. I think your issue is a IPV4/IPV6 confusion.

Instead of putting your actual IP on the listen parameter please try this instead:

Listen 0.0.0.0:80

This tells apache to listen only on the IPV4 address range, as did your change, but without needing to specify a specific ip. Your site should then work locally and from other PC's on your network without needing to change anything.
You would still address your site using the WAMP PC's ip address as you have done.


RE: Allowing the world into your site

First you have to Port Forward your router. This basically tells your router to ignore its NAT security for a single port, and allow extenal access on port 80 to come into your network. The forwarding part tells the router to send all external requests on port 80 to a specific ip address in your internal network i.e. the ip address of the PC running Apache.

So now you will definitely have to make that PC have a STATIC ip address and not one allocated by DHCP so that it is always on the same ip and there to accept the packets.

You may have to also configure your firewall to allow TCP connections on port 80 to enter your Apache's PC.


External users would then address your site as http : // WAN IP ADDRESS/



RE: I Have to use the index.php on the address

Please check this section of your httpd.conf

<IfModule dir_module>
DirectoryIndex index.php index.html index.htm
</IfModule>

If it does not mention 'index.php' in the list of files names to look for please add it.
If it does then something else is hinky!

Options: ReplyQuote
Re: Other people cannot access my localhost
Posted by: patagonik (---.speedy.com.ar)
Date: March 08, 2013 05:17AM

Hi! i have same issue, folow the instructions, but down´t work. Others PCs in my LAN cant reach apache.

the only diference i have is a static IP and in httpd.conf file

<Directory "d:/wamp/www/">
......

# onlineoffline tag - don't remove


Require local
Allow from 192.168.0


</Directory>

any ideas? tanks-

Options: ReplyQuote
Re: Other people cannot access my localhost
Posted by: RiggsFolly (---.as13285.net)
Date: March 08, 2013 10:00AM

As you have a 'Require local' syntax, I assume you are using Apache 2.4.x

The syntax for Apache 2.4.x is 'Require ip ...' so for example to allow every IP on your subnet

Require ip 192.168.1

would be the syntax

To allow just 2 spscific ip's would be

Require ip 192.168.1.10 192.168.1.11


Apache Documentation : [httpd.apache.org]

Options: ReplyQuote
Re: Other people cannot access my localhost
Posted by: patagonik (---.speedy.com.ar)
Date: March 08, 2013 05:50PM

Thank you for the response RiggsFolly.
I made the chages, but stil not work.
as u figure im using apache 2.4.2

Options: ReplyQuote
how to acces my local host from my office
Posted by: chidollar (---.mtn.cm)
Date: March 16, 2013 12:20AM

i am very impressed with the explanations u gave regarding a similar topic. i am begging you to please take some time and explain to me how i can acees my localhost(joomla site) while at work using the internet.

Options: ReplyQuote
Re: Other people cannot access my localhost
Posted by: zdy (---.137.48.58.broad.wh.hb.dynamic.163data.com.cn)
Date: March 17, 2013 11:57AM

This is provided that all machines are on the same network and that you have administrative privileges on the machines (you'll have to edit some system files).

You can easily do this but it would have to be a manual process.

You have to create an entry in the hosts file -

On Windows machines is is located in %SystemRoot%\system32\drivers\etc\hosts
On UNIX like systems it is located in /etc/hosts
[en.wikipedia.org].
See the link for details on where your hosts file is located. It depends on the operating system.

The following will have to be done on every machine that you would like
to have access to your localhost machine.

Add a line at the very end of your hosts file similar to this :

10.0.0.42 prathyash-localhost.com
The IP address (in the example above it is 10.0.0.42) is the address of your localhost; Your computers IP address. The domain name (prathyash-localhost.com) is what is mapped to the IP address.

After you save that file, whenever that computer points to prathyash-localhost.com, it will be directed to your IP address. Firewalls are still a barrier - however the other answers covered that so I will not repeat their contribution. www.cusabio.com/ELISA_Kit-84598 il-6 elisa kit

Depending on your situation, manually editing tens maybe hundreds of files might not be feasible. In this case, you might want to consult the networks administrator (he probably hangs around on Server Fault), and he may have a better solution for you.

Options: ReplyQuote


Sorry, only registered users may post in this forum.