Page 1 of 1

XAMPP redirects other LAN computers to domain/dashboard

PostPosted: 30. September 2016 23:30
by WebDev.Newbie
Hi Everyone,

I trust that this post is in the correct section, if not please accept my apology.

I have XAMPP 5.6.24 installed on Windows 7 and wants to test the site from other computes/devices on my LAN. I even see the same behaviour on my android tablet after editing its hosts file.

When I type my-domain.local or my-ssl-domain.local in the browser's address bar it redirects to my-domain.local/dashboard and my-ssl-domain.local/dashboard respectively.

This is what I have done to date.

Amending the hosts files of the computers
Code: Select all
# Added the following entries to the hosts file (C:\Windows\SYSTEM32\drivers\etc\)
# of the host computer 192.168.1.20.

127.0.0.1 www.my-domain.local
127.0.0.1 my-domain.local

127.0.0.1 www.my-ssl-domain.local
127.0.0.1 my-ssl-domain.local



Code: Select all
# Added the following entries to the hosts file # (C:\Windows\SYSTEM32\drivers\etc\)
#  of the client computer accessing the XAMPP web server  from 192.168.1.21.
127.0.0.1 www.my-domain.local
127.0.0.1 my-domain.local

127.0.0.1 www.my-ssl-domain.local
127.0.0.1 my-ssl-domain.local


Edited the httpd.conf
Code: Select all
# Made sure this module in the file was uncommented.
Include etc/extra/httpd-vhosts.conf

# Replace DocumentRoot w:/xampp/htdocs- w:/xampp/htdocs with d:/www
DocumentRoot "w:/www"
<Directory "w:/www">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require All granted
</Directory>


Setup of http and https redirection of vhosts
Code: Select all
<VirtualHost localhost>
    DocumentRoot "w:/www/xampp/htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost my-domain.local:80>
   ServerName my-domain.local
    DocumentRoot "w:/www/my-domain.local"
    ServerAdmin webtech@my-domain.com

    # Server Aliases
    ServerAlias www.my-domain.local

    # setup logging
    LogLevel error
    ErrorLog "logs/my-domain.local-error.log"
    CustomLog "logs/my-domain.local-access.log" combined

     # Directory permissions
    <Directory "w:/www/my-domain.local">
      Options Indexes FollowSymLinks Includes ExecCGI
      AllowOverride All
      Require All granted
      Allow from 192.168.1.15/255.255.255.240
    </Directory>
</VirtualHost>


# Redirect https:// traffic.
<VirtualHost my-ssl-domain.local:80>
    ServerName www.my-ssl-domain.local
    # Server Aliases
    ServerAlias my-ssl-domain.local
   
         # Redirect all server aliases to https://
    # --------------------------------------------------------
    Redirect permanent /  https://www.my-ssl-domain.local
    </VirtualHost>



Changes to httpd-ssl.conf

Code: Select all
<VirtualHost my-ssl-domain.local:443>

#   General setup for the virtual host
 DocumentRoot "w:/www/my-ssl-domain.local"
 ServerName www.my-ssl-domain.local
 ServerAdmin webtech@my-ssl-domain.com
 
     # setup logging
 ErrorLog "d:/xampp/apache/logs/error.log"
 TransferLog "d:/xampp/apache/logs/access.log"

#   SSL Engine Switch:
#   Enable/Disable SSL for this virtual host.
 SSLEngine on

#   Server Certificate:
 SSLCertificateFile "conf/ssl.crt/my_ssl_domain.crt"

#   Server Private Key:
 SSLCertificateKeyFile "conf/ssl.key/my_ssl_domain.key"

#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
 <FilesMatch "\.(cgi|shtml|phtml|php)$">
     SSLOptions +StdEnvVars
 </FilesMatch>
 <Directory "d:/xampp/apache/cgi-bin">
     SSLOptions +StdEnvVars
 </Directory>

#   SSL Protocol Adjustments:
 BrowserMatch "MSIE [2-5]" \
          nokeepalive ssl-unclean-shutdown \
          downgrade-1.0 force-response-1.0

#   Per-Server Logging:
 CustomLog "d:/xampp/apache/logs/ssl_request.log" \
           "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

    <Directory "w:/www/my-ssl-domain.local">
      Options ExecCGI FollowSymLinks Includes Indexes
      Order Deny,Allow
      AllowOverride FileInfo Limit Indexes Limit
      Allow from 192.168.1.15/255.255.255.240
    </Directory>
 </VirtualHost>                           



Thanks in advance for your time and effort. All help and guidance will be appreciated.

Re: XAMPP redirects other LAN computers to domain/dashboard

PostPosted: 01. October 2016 01:05
by Altrea
Hi,

WebDev.Newbie wrote:<VirtualHost my-ssl-domain.local:80>

Don't use hostnames in the <VirtualHost> Declaration. It does not work as you would expect.
This does not separate requests. It will not use any request data at all.
If you place a hostname at this place your server will resolve the name to an ip at the time Apache gets started. Because this hostname will get resolved to 127.0.0.1 on your server it will only get triggert for requests coming from 127.0.0.1.

Always use the wildcard <VirtualHost *:80> except you have really good reasons to not do.

best wishes,
Altrea