Issue with conflicting authorization access

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Issue with conflicting authorization access

Postby pmonett » 18. June 2011 17:53

I have two virtual hosts configured. One is at the address site1.net, the second is at site1.admin.net.

The directories are seperate.

The access to site1 is to be secured via .htaccess. That works fine, but I found in test that, due to the hierarchy of the site names, site2 is also protected. It shouldn't be.

Why is site2 under the same .htaccess protection as site1 when it doesn't even have a .htaccess file ? What can I do to make site2 "public" again ?

Thanks for any tips,

Pascal.
pmonett
 
Posts: 5
Joined: 15. June 2011 09:19

Re: Issue with conflicting authorization access

Postby JonB » 18. June 2011 20:44

well if you nested them in your directory structure, that's exactly what would happen

Vhosts need to be parallel or in different directory trees.

./sites
./sites/site1
./sites/site2

OR

./sites/site1
./othersites/site2
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Issue with conflicting authorization access

Postby pmonett » 18. June 2011 21:30

It would appear that I was not clear enough when I stated that the physical directories are seperate, it is just the URLs that appear hierarchical.

Thus I should specify that site1 is stored in /site1, whereas site2 is stored in /site2.

That is why I don't understand why data stored in /site2 are subject to the same authorization test as the data in /site1.
pmonett
 
Posts: 5
Joined: 15. June 2011 09:19

Re: Issue with conflicting authorization access

Postby JonB » 20. June 2011 19:18

actually, that might very well be the way .htaccess is intended to work.

http://httpd.apache.org/docs/current/ho ... ccess.html

Further note that Apache must look for .htaccess files in all higher-level directories, in order to have a full complement of directives that it must apply. (See section on how directives are applied.) Thus, if a file is requested out of a directory /www/htdocs/example, Apache must look for the following files:

/.htaccess
/www/.htaccess
/www/htdocs/.htaccess
/www/htdocs/example/.htaccess

And so, for each file access out of that directory, there are 4 additional file-system accesses, even if none of those files are present. (Note that this would only be the case if .htaccess files were enabled for /, which is not usually the case.)

I think it is actaully using URL's to make the discrimination, why don't you make a change to un-nest the hostnames, and then see what happens???

Good Luck
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Issue with conflicting authorization access

Postby Sharley » 21. June 2011 03:55

Sometimes 2 heads are better than one when troubleshooting these issues. :wink: :)
pmonett wrote:I have two virtual hosts configured. One is at the address site1.net, the second is at site1.admin.net.

The directories are seperate.
Your issue may well be in how the vhosts are configured and if there are any issues with them then the first good vhost becomes the default and the rest are ignored.

Perhaps you could again paste here your httpd-vhost.conf file and your relevant hosts file entries so I can try and see where you may have an issue - you can obfuscate any sensitive settings you don't want to be generally known, or you could send me a forum pm (personal message) with those details, which is even more private.

Usually each vhost container is treated by Apache as a separate server with it's own DocumentRoot, which will determine the behavior of the directory tree beneath it.

How does the current httpd-vhosts.conf file vary from my last post to you that produced a positive response with a good working example?
viewtopic.php?p=181327#p181327

I may be able to get a better handle on your .htaccess issue if I can take a look at the 2 above mentioned configuration settings files and then try and replicate it on my PC.


Perhaps all you need do is add or replace these 2 lines in the <Directory> directive of the vhosts that contains the .htaccess file but omit the AllowOverride All in the vhosts that does not include the .htaccess file
Code: Select all
Options Indexes +FollowSymLinks Includes ExecCGI
AllowOverride All
AllowOverride All means to read any .htaccess file in the directory tree that contains a .htaccess file, if it is omitted then the .htaccess file will be ignored.

Best wishes.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: Issue with conflicting authorization access

Postby pmonett » 02. July 2011 10:42

Thank you for your interest in my little problem.

I post below the httpd-vhosts configuration file for your perusal, and because I want all other beginners to learn what they should not do :) :

NameVirtualHost *:80

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "C:/localhost"
ServerName localhost

<Directory "C:/localhost">
AllowOverride Options AuthConfig
Options -Indexes
Order deny,allow
Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "C:/localhost/site1"
ServerName localhost/site1

<Directory "C:/localhost/site1">
AllowOverride Options AuthConfig
Options Indexes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "C:/192_168_10_20"
ServerName myip

<Directory "C:/192_168_10_20">
AllowOverride Options AuthConfig
Options -Indexes
Order deny,allow
Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "C:/site2"
ServerName myip/site2

<Directory "C:/site2">
AllowOverride Options AuthConfig
Options -Indexes +ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Keep in mind that this is a Windows server configuration, thus the quotes around the directory paths.
pmonett
 
Posts: 5
Joined: 15. June 2011 09:19

Re: Issue with conflicting authorization access

Postby Sharley » 02. July 2011 11:26

Where did you install XAMPP - did you install XAMPP in C:\localhost?

The localhost VirtualHost below should reflect the htdocs folder in the XAMPP installation folder.
Normally C:\xampp\htdocs
or in your case
C:\localhost\htdocs if you installed XAMPP in the C:\localhost folder.

In the httpd.conf file in the apache\conf folder what does the line
ServerName
Have entered in there?
What does the
<DocumentRoot>
Have entered in there?
What does the
<Directory>
further down have entered in it?
Should be the same as the DocumentRoot

If the above is not reflected in the localhost VirtualHost below then you may have issues that prevent Apache from starting.

You may need to edit the localhost VirtualHost to reflect what you have in the httpd_conf file mentioned above.

Try these and remember to save the files after editing and then restart Apache.
If Apache can't start then read the apache\error.log file.
Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/localhost/htdocs"
ServerAdmin webmaster@localhost
<Directory "C:/localhost/htdocs" >
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName site1
DocumentRoot "C:/localhost/site1"
<Directory "C:/localhost/site1" >
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ "C:/localhost/site1/cgi-bin/"
ServerAdmin webmaster@localhost
CustomLog site1_access.log combined
ErrorLog site1_error.log
LogLevel error
</VirtualHost>

<VirtualHost *:80>
ServerName myip
DocumentRoot "C:/192_168_10_20"
<Directory "C:/192_168_10_20" >
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>
ScriptAlias /cgi-bin/ "C:/192_168_10_20/cgi-bin/"
ServerAdmin webmaster@localhost
CustomLog myip_access.log combined
ErrorLog myip_error.log
LogLevel error
</VirtualHost>

<VirtualHost *:80>
ServerName site2
DocumentRoot "C:/site2"
<Directory "C:/site2" >
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ "C:/siye2/cgi-bin/"
ServerAdmin webmaster@localhost
CustomLog site2_access.log combined
ErrorLog site_2error.log
LogLevel error
</VirtualHost>[/code/

C:\Windows\system32\drivers\etc\HOSTS file
Add these entries so they are the first in the list.
[code]127.0.0.1 localhost
127.0.0.1 site1
127.0.0.1 myip
127.0.0.1 site2


These URIs can be typed in the browser to access each vhosts.
http://localhost
http://site1
http://myip
http://site2


TIP
When creating VirtualHost configurations in the httpd-vhosts.conf file it is best to start with one container and test that it works.

Then add another and then test that both work correctly

Then another and test again and so on.

This way you can easily spot any errors or typos in an individual container rather than trying to configure them all at the same time with not much hope and great difficulty trying to locate the offender.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 137 guests