VirtualHost errors
Posted by: sildeag (---.cg.shawcable.net)
Date: March 13, 2016 03:44AM

1 - Windows version: Windows 10 64 bit
2 - Version WampServer (Specify version number AND whether 32 or 64 bit): ver 3_x64 and 64 bit
3 - Apache Version 2.4.17
4 - PHP Version 5.6.16 - 7.0
5 - MySQL Version 5.7.9
6 - What color is the WampServer icon (in the notification area of the taskbar) Green


1) The number of <VirtualHost does not match the number of ServerName in C:/wamp64/bin/apache/apache2.4.17/conf/extra/httpd-vhosts.conf file


2) It's a bad idea to add localhost in the url of launching projects. It is best to define VirtualHost in
wamp/bin/apache/apache2.4.17/conf/extra/httpd-vhosts.conf
file and not add localhost in the url.

I would like to correct these errors because they are annoying, setup my configuration for safe localhost access only, and I also want to understand why the listener in "httpd.conf" has
lines:

Listen 127.0.0.1:80
Listen [::0]:80

The first line I understand but the second I would have expected [::1]:80 not [::0]:80

My other files are below.

Thanking you in advance for any help.

Gordon

File "httpd-vhosts.conf" contents:

# for localhost to work properly

<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/wamp64/www"
<Directory "c:/wamp64/www">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
# You would never want a remote user to see this
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName postal
DocumentRoot c:/postal
<Directory "c:/postal/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>


File "hosts" contents:

# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
127.0.0.1 postal
::1 postal



Edited 1 time(s). Last edit at 03/13/2016 04:09AM by sildeag.

Options: ReplyQuote
Re: VirtualHost errors
Posted by: Otomatic (Moderator)
Date: March 13, 2016 10:04AM

Hi,

> why the listener in "httpd.conf" has lines:
> Listen 127.0.0.1:80
> Listen [::0]:80

At installation of Wampserver 3, the listener has lines:
Listen 0.0.0.0:80
Listen [::0]:80
ie all ip on port 80, so you have modified these lines.

> Order Deny,Allow
> Deny from all
> Allow from 127.0.0.1
> Allow from ::1
NO, NO, and NO. This is old Apache 2.2 syntax. You MUST use Require local.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: VirtualHost errors
Posted by: RiggsFolly (Moderator)
Date: March 13, 2016 02:45PM

Corrected Virtual Host definitions


<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "C:/wamp64/www"
    <Directory "c:/wamp64/www">
# You would never want a remote user to see this
       require local
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName postal
    DocumentRoot c:/postal
    <Directory "c:/postal/">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

The `Require local` covers `localhost`, `127.0.0.1` and `::1` i.e. IPV4 and IPv6 loopback addresses
This tella Apache only allow access to this site from THIS machine

If you ever want to allow access to a site from a PC on your local network you can do

    Require local
    Require ip 192.168.0.100

If you want to allow an PC on your local network you can do

    Require local
    Require ip 192.168.0

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote


Sorry, only registered users may post in this forum.