Virtual host rules for localhost overriding those for test online virtual host
Posted by: tazer1917 (---.ph.ph.cox.net)
Date: December 31, 2019 06:38AM

Hello,

Answers to questions:
Windows version: Windows 10 Version 10.0.18362 Build 18362 x64
2 - Version WampServer: 3.2.0 x64
3 - Apache Version: 2.4.41
4 - PHP Version: 7.3.12
5 - MySQL Version: 8.0.10
5a - MariaDB version: 10.4.10
6 - WampServer icon is green
8 - I have access to localhost under localhost:81 and there are no error messages.
9 - I have access to phpMyAdmin
11- no antivirus, using windows firewall
12 - C:\wamp64\

Here is my httpd-vhosts.conf:

<VirtualHost *:81>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>


#
<VirtualHost *:81>
ServerName testonline
DocumentRoot "c:/wamp64/www/testonline"
<Directory "c:/wamp64/www/testonline/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>


Note that I have changed my port to 81 to avoid skype conflicts and as a test of my proficiency operating my router's port forwarding settings.

While trying to test setting up an online server, I ran into an issue where I would receive a 403 error when my httpd-vhosts.conf is configured as so and I accessed the site as myip:81/testonline. However, when I change the require line in the localhost section to "Require all granted", I do not have this error and able to access my site in the same manner. I wouldn't like to leave it this way as this gives access to my localhost site. Is there a way to fix this?

Error message:
Forbidden

You don't have permission to access this resource.
Apache/2.4.41 (Win64) PHP/7.3.12 Server at 70.176.41.203 Port 81

Browsing through similar forum topics, it seems that this issue is unique to me which makes me think it may be due to my httpd.conf settings, however I do not know where to look within the file, or what to change. It could also be my own misunderstanding of how to access my site while it is online.

Additionally, while I followed the instructions given in the sticky topic, I am not sure if my virtual host is set up correctly.

Any help would be appreciated.

Thank you!



Edited 2 time(s). Last edit at 12/31/2019 06:54AM by tazer1917.

Options: ReplyQuote
Re: Virtual host rules for localhost overriding those for test online virtual host
Posted by: Otomatic (Moderator)
Date: December 31, 2019 10:41AM

Hi,

Apply item 03 of TROUBLESHOOTING TIPS

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

Options: ReplyQuote
Re: Virtual host rules for localhost overriding those for test online virtual host
Posted by: tazer1917 (---.ph.ph.cox.net)
Date: December 31, 2019 07:20PM

Hello,

My issues still arise after uninstalling Skype.

Options: ReplyQuote
Re: Virtual host rules for localhost overriding those for test online virtual host
Posted by: Otomatic (Moderator)
Date: January 01, 2020 04:43PM

Hi,

Reset port 80 in the VirtualHost and wherever you previously changed it.
Reset any other changes you may have made.

You can try to put the <Directory structure outside the <VirtualHost structure:
<VirtualHost *:80>
  ServerName testonline
  DocumentRoot "c:/wamp64/www/testonline"
</VirtualHost>
<Directory "c:/wamp64/www/testonline/">
  Options +Indexes +Includes +FollowSymLinks +MultiViews
  AllowOverride All
  Require all granted
</Directory>

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

Options: ReplyQuote
Re: Virtual host rules for localhost overriding those for test online virtual host
Posted by: tazer1917 (---.ph.ph.cox.net)
Date: January 02, 2020 01:30AM

Hello,

I reinstalled WampServer in order to erase any changes I had made. I made a new virtual host and configured it as suggested, with the <Directory structure outside of the <VirtualHost structure. I fixed my port forwarding and tried to access my test site from my phone over cellular and it worked. I then tried to access my homepage through the same method on my phone and was denied.

Thank you very much for your help.

While it works as intended from my point of view, is there a reason that having the <Directory structure inside of the <VirtualHost structure did not work for me?

Thank you again,
Tazer

Options: ReplyQuote
Re: Virtual host rules for localhost overriding those for test online virtual host
Posted by: Jameson (---.hsd1.nm.comcast.net)
Date: January 06, 2020 07:49PM

He was trying to change the scope, but in the forum posts about virtual servers they use the same scope so i can't see why that would work.
I am having the same problem, If i put Require all granted at the top of the file, then it works, but if local is on the top, it doesn't. The only reason I don't like having it setup like that though is because the forum post of why we need to setup virtual servers, in there it says that you want to have local first, as it is the default directory people will get to if they use your WAN IP. I think this might be confusing though, as i think the forum post is strictly talking about setting up virtual servers on local networks and not live servers. However later in the post they talk about being able to make changes in the VHOST file to specific websites only, but the example he gives doesn't show a complete VHOST file, just a snippet of the server config for his "1 hour to show the client" snippet.

Options: ReplyQuote
Re: Virtual host rules for localhost overriding those for test online virtual host
Posted by: Otomatic (Moderator)
Date: January 06, 2020 09:01PM

Hi,

> If i put Require all granted at the top of the file, the it works
If you think about the complete structure - including the includes - of the Apache configuration file, you might see that this applies to the entire Apache server itself and becomes a security hole.

All hosting providers use VirtualHost. As a customer of the hosting provider, you don't realize this because it's not you who creates the VirtualHost, but the hosting provider and before you even upload your site to it.

With Wampserver (or any other local server), the hoster is you and it is up to you to learn how to use a server. Skills and knowledge are, unfortunately, not part of the Wampserver package.
We are not magicians and we can't turn you into a :
- Network Administrator
- Web Server Administrator
- Database Administrator
- Developer
- Analyst
- Programmer.

Nevertheless, all the links on the related documentation are an integral part of Wampserver.

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

Options: ReplyQuote
Re: Virtual host rules for localhost overriding those for test online virtual host
Posted by: Jameson (---.hsd1.nm.comcast.net)
Date: January 06, 2020 09:44PM

I am a programmer, but this doesnt not mean i know how to use the software right off the bat.
Here is what i figured out from playing around with it, you guys can tell me if this is right or wrong, but for me it's working.

Server name has the be the .com you are trying to make. For me, I purchased a domain name, but you can use thing like noip.com to set you WAN IP to a domain name like test.hopto.org (which you do on there site). After that I just put my test.hopto.org as the server name. This fixed the problem, now it's not first in the list of vhosts, but you can connect to it from outside computers.

I didnt put a entry in the .host file in system 32 because I don't want to connect to my own computers, i want to go out onto the web when i put in test.hopto.org into the browser. This only works if test.hopto.org points to your WANIP. If you purchase your domain online, there will be what they call a "A" file that you setup to point from you domain name (.com) to you WANIP. This is by no means final, i suggest going into the apache documentation and reading about authorization and access. There is lots of tips in there that can show you different dangers and how to prevent them. The documentation (http://httpd.apache.org/docs/2.4/en/vhosts/name-based.html) says the following : Of course, you can't just make up names and place them in ServerName or ServerAlias. You must first have your DNS server properly configured to map those names to an IP address associated with your server. (this is the A file I wrote about ealyer)
# 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 test.hopto.org
ServerAlias www.test.hopto.org
DocumentRoot "c:/website/testonline/www>
<Directory "c:/website/testonline/www">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>



Edited 5 time(s). Last edit at 01/06/2020 11:39PM by Jameson.

Options: ReplyQuote


Sorry, only registered users may post in this forum.