Page 1 of 1

[solved]how to access localhost website from local network

PostPosted: 14. June 2012 16:30
by drasgan
I run a website on localhost XAMPP computer which is accessible from localhost computer by typing in the browser address bar:
http://mydomain.local
But it only works on the local XAMPP computer. I'd like to allow another computer in the same LAN to access the website. I've configured the other computer hosts file to contain line:
192.168.3.149 mydomain.local
where 192.168.3.149 is the XAMPP computer IP address. But after typing the http://mydomain.local on the other computer browser, after pressing enter, the address becomes: http://mydomain.local/xampp and some strange page opens. (by the way, this is the same page which would open on the localhost XAMPP computer after typing http://localhost/xampp in its browser address). So I would conclude that the other computer reaches the XAMPP computer, but for some reason, instead of going to the mydomain.local host, it goes to xampp default page.

So far, I have done this:

Changed I:\xampp\apache\conf\extra\httpd-xamp.conf file to contain this (see "Allow from" containing 192.168.3 - it should allow access from the whole subnet):
Code: Select all
# Close XAMPP sites here
<LocationMatch "^/(?i:(?:xampp|licenses|phpmyadmin|webalizer|server-status|server-info))">
    Order deny,allow
    Deny from all
    Allow from ::1 127.0.0.0/8 192.168.3
    ErrorDocument 403 /error/HTTP_XAMPP_FORBIDDEN.html.var
</LocationMatch>


On my XAMPP computer, I have the following configuration in I:\xampp\apache\conf\extra\httpd-vhosts.conf:
Code: Select all
NameVirtualHost mydomain.local:80
<VirtualHost mydomain.local:80>
    ServerAdmin postmaster@dummy-host2.localhost
    DocumentRoot "I:/xampp/htdocs/myphpapp"
    ServerName mydomain.local
    ServerAlias mydomain.local
    ErrorLog "logs/mydomain.local-error.log"
    CustomLog "logs/mydomain.local-access.log" combined

<Directory "I:/xampp/htdocs/myphpapp">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>


I don't know what else to check. Please help.

Re: how to access localhost website from local network

PostPosted: 14. June 2012 18:23
by JonB
See if this post helps - its a very close situation

8)

Re: how to access localhost website from local network

PostPosted: 14. June 2012 21:00
by drasgan
Which post?

Re: how to access localhost website from local netw

PostPosted: 15. June 2012 10:54
by drasgan
I noticed the following entries in access.log, when trying to access XAMPP computer from another LAN computer:
Code: Select all
192.168.3.196 - - [15/Jun/2012:11:42:35 +0200] "GET / HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 6.0) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5"
192.168.3.196 - - [15/Jun/2012:11:42:35 +0200] "GET /xampp/ HTTP/1.1" 403 1332 "-" "Mozilla/5.0 (Windows NT 6.0) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5"

I think the problem is in the second line. Why is it redirecting from "/" to "/xampp" ??

Compare it to the correct example (when accessing from localhost):
Code: Select all
127.0.0.1 - - [15/Jun/2012:11:46:38 +0200] "GET /myphpapp..../.../... HTTP/1.1" 304 - "http://mydomain.local/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5"

In this second case, I am GETting the correct address.

Why apache treats the same web address differently from LAN computer and from localhost? Which configuration option is responsible?

Re: how to access localhost website from local netw

PostPosted: 15. June 2012 12:10
by JonB
this one:

viewtopic.php?f=16&t=50788


Good Luck
8)

Re: how to access localhost website from local netw

PostPosted: 15. June 2012 12:21
by drasgan
Thanks but as I mentioned in my first post, the other computer has already the "hosts" file correct. Otherwise, it wouldn't reach my XAMPP computer using the domain name.

Re: how to access localhost website from local netw

PostPosted: 15. June 2012 13:14
by Altrea
Hi drasgan,

In your VHost definition, please change the first two lines to
Code: Select all
NameVirtualHost *:80
<VirtualHost *:80>


Restart your Apache and try again to request.

best wishes,
Altrea

Re: how to access localhost website from local network

PostPosted: 15. June 2012 14:33
by drasgan
Thanks 100x, it worked!