Access to virtual host from internet
Posted by: einfall (---.teremki.kiev.ua)
Date: February 22, 2019 02:26PM

Hi!

My config is:
Win7 x64 (SP1)
WampServer Version 3.1.7 64bit
Apache 2.4.37
PHP 7.12.14
MySQL 5.7.24
WampServer icon is green (and start/stop/restart services works fine)

I want to create access to virtual host from internet.

What I've done:
1. Create rules for ports 80 and 443 forwarding on my router. It works.
2. Create Windows Firewall inbound rule for ports 80 and 443. It works too.
3. Change Require local to Require all granted in httpd-vhosts.conf in localhost section, Restart All Services and get access to localhost from internet. All it works.
4. Create Virtual Host with name WampShared via Add a Virtual Host from Tools menu.
5. In WampShared virtual host directory I create index.php file with simple echo command. It works on [wampshared] address.
6. Change Require local to Require all granted in httpd-vhosts.conf in WampShared section and change back Require all granted to Require local in localhost section. Restart All Services.

Now I see "Forbidden You don't have permission to access / on this server" message.

7. Disable Antivirus, just in case. Nothing changed.

My httpd-vhosts.conf is:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>


#
<VirtualHost *:80>
ServerName WampShared
DocumentRoot "e:/wamp_shared"
<Directory "e:/wamp_shared/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>


Lines in C:\Windows\System32\drivers\etc\hosts:
127.0.0.1 localhost
::1 localhost

127.0.0.1 WampShared
::1 WampShared

What could be wrong? Why localhost works, but WampShared don't?

Thanks.

Options: ReplyQuote
Re: Access to virtual host from internet
Posted by: RiggsFolly (Moderator)
Date: February 22, 2019 05:01PM

You could try

ServerName wampshared

and

127.0.0.1 wampshared
::1 wampshared

as a first attempt

---------------------------------------------------------------------------------------------
(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
Re: Access to virtual host from internet
Posted by: einfall (---.teremki.kiev.ua)
Date: February 22, 2019 05:57PM

Doesn't work. I tried several options, another virtual hosts etc. Only localhost works.

Options: ReplyQuote
Re: Access to virtual host from internet
Posted by: einfall (---.teremki.kiev.ua)
Date: February 22, 2019 08:58PM

Solved.
The solution is reordering VirtualHost sections. ) I thought the only Require all granted/Require local directives is important... RTFM, RTFM. )

Options: ReplyQuote
Re: Access to virtual host from internet
Posted by: RiggsFolly (Moderator)
Date: February 23, 2019 01:17PM

Hi

The order should not matter.

However Apache will fall back to the first VH defined if it cannot find the domain used in the browsers address bar.

To access the domain `wampshared` you should be using `http ://wampshared` is that the url you were using?

---------------------------------------------------------------------------------------------
(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
Re: Access to virtual host from internet
Posted by: einfall (---.teremki.kiev.ua)
Date: February 23, 2019 08:29PM

Hi!

I needed access form internet to my virtual host (not from local net, where I could edit hosts files etc.). As far as I know, I can use only my (static) IP-address in this case. This is from httpd.apache.org: "...only the order of the VirtualHost directives for one address set is important..." Probably everything is correct. )

Thanks.



Edited 1 time(s). Last edit at 02/23/2019 08:30PM by einfall.

Options: ReplyQuote
Re: Access to virtual host from internet
Posted by: RiggsFolly (Moderator)
Date: February 24, 2019 12:40PM

Hi

[forum.wampserver.com]

---------------------------------------------------------------------------------------------
(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
Re: Access to virtual host from internet
Posted by: ciprianmp (---.131-242-81.adsl-dyn.isp.belgacom.be)
Date: April 16, 2020 02:31AM

I have the same issue.
I am trying to reach my website from internet, but I don't anyone to actual access the index file of wampserver.
I have these virtual hosts defined:
# Virtual Hosts
#
<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "${INSTALL_DIR}/www/plus"
    ServerName  plus
    ServerAlias www.plus
    <Directory  "${INSTALL_DIR}/www/plus">
		Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
		Require all granted
    </Directory>
</VirtualHost>

If I switch order (plus first), when I go to the main website address it opens plus directly on port 80 (not what I want, I need /plus to be in the address) and cannot find any other vhost I defined.

If I change main vhost to Require all granted, all following subdirectories/vhosts become accessible, including those set as local (phpmyadmin included, but that is protected by the alias).

What is the actual solution to have subdirectories visible but not the main index nor those set as local only? Is using alises the solution?

Maybe a detailed example with multiple vhosts/subdirectories will help us understand the safest/proper way to setup vhosts.

PS: on the Apache 2.4 documentation, it does say it only takes the first Vhost in the account. Their example for subdirectories found under the www main folder is to use rewrite engine on and redirects, but I don't think that is reliable either.

Thank you! Stay safe everyone!

Ciprian M.

Options: ReplyQuote
Re: Access to virtual host from internet
Posted by: Otomatic (Moderator)
Date: April 16, 2020 08:55AM

Hi,

One solution may be to move the <Directory structure ... </Directory> outside the <VirtualHost structure ... like this:
<VirtualHost *:80>
  DocumentRoot "${INSTALL_DIR}/www/plus"
  ServerName  plus
  ServerAlias www.plus
</VirtualHost>
<Directory  "${INSTALL_DIR}/www/plus">
  Options +Indexes +Includes +FollowSymLinks +MultiViews
  AllowOverride All
  Require all granted
</Directory>
In theory, this has no effect on the verification of VirtualHost internal to Wampserver, but has an effect on the possibility of deleting a VirtualHost in the Add VirtualHost page, only the <VirtualHost ...</VirtualHost> structure will be deleted and not the related Directory structure.

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

Options: ReplyQuote
Re: Access to virtual host from internet
Posted by: RiggsFolly (Moderator)
Date: April 16, 2020 12:38PM

Ciprian

I am very interested to know WHY you say you NEED the /plus in the URL? I cannot think of a good reason for this unless its a coding mistake that is too late to fix

---------------------------------------------------------------------------------------------
(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.