Subdomain directory not resolved correcty?

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

Subdomain directory not resolved correcty?

Postby gator » 18. July 2020 04:45

Hi All,

For some reason, subdomain I set up doesn't get resolved to correct directory, not quite sure why. I've been researching the issue last 4 days, can't spot the issue in my config, I hope you guys can help.
So, my setup:
xampp 3.2.2, apache 2.4 windows 10.

Trying to configure separate subdomain for images in this instance. Everything seems to be working, subdomain is accessed, subdomain logs get populated, except for the part where the subdomain directory isn't resolved correctly, and I can't get it to work.
Base url access is fine, http://mysite.com/dir/textfile.html works.
However, http://images.mysite.com/icons/icon1.png results in 404, and I get an entry in subdomain's error log - images.mysite.access.log, like so:

127.0.0.1 - - [17/Jul/2020:19:39:00 -0700] "GET /icons/icon1.png HTTP/1.1" 404 1260

If that path (/icons/icon1.png) was appended to specified DocumentRoot for images vhost (c:/Dev/websrc/mysite/images) it would be fine, file is there, and I can access that file from base url just fine, in other words, this works:
http://mysite.com/images/icons/icon1.png, but this doesn't - http://images.mysite.com/icons/icon1.png
My best guess is that images vhosts DocumentRoot is ignored and request is going to what?

Also, same config works on my public server(linux based), it's just with xampp/windows that I am having this strange issue.

windows hosts file:

127.0.0.1 mysite.com
127.0.0.1 images.mysite.com

httpd.conf:
<Directory />
AllowOverride none
Require all granted
</Directory>

httpd-vhosts.conf:

<VirtualHost *:80>
ServerName mysite
ServerAlias www.mysite.com
DocumentRoot "c:/Dev/websrc/mysite"
<Directory "c:/Dev/websrc/mysite">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName images.mysite
ServerAlias images.mysite.com
ServerAlias www.images.mysite.com

ErrorLog "logs/images.mysite.error.log"
CustomLog "logs/images.mysite.access.log" combined

DocumentRoot "c:/Dev/websrc/mysite/images"
<Directory "c:/Dev/websrc/mysite/images">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

httpd -S output:
VirtualHost configuration:
*:80 is a NameVirtualHost
default server mysite (C:/Dev/xampp/apache/conf/extra/httpd-vhosts.conf:17)
port 80 namevhost mysite (C:/Dev/xampp/apache/conf/extra/httpd-vhosts.conf:17)
alias www.mysite.com
port 80 namevhost images.mysite (C:/Dev/xampp/apache/conf/extra/httpd-vhosts.conf:28)
alias images.mysite.com
alias www.images.mysite.com
*:443 www.example.com (C:/Dev/xampp/apache/conf/extra/httpd-ssl.conf:121)
ServerRoot: "C:/Dev/xampp/apache"
Main DocumentRoot: "C:/Dev/websrc/mysite"
Main ErrorLog: "C:/Dev/xampp/apache/logs/error.log"
Mutex ssl-stapling-refresh: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="C:/Dev/xampp/apache/logs/" mechanism=default
PidFile: "C:/Dev/xampp/apache/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: SRVROOT=C:/Dev/xampp/apache


Thanks,
Gator
gator
 
Posts: 5
Joined: 18. July 2020 03:43
XAMPP version: 3.2.2
Operating System: Windows 10

Re: Subdomain directory not resolved correcty?

Postby Nobbie » 18. July 2020 17:46

Probably there is an invalid rewrite/redirect in an .htaccess file.
Nobbie
 
Posts: 11771
Joined: 09. March 2008 13:04

Re: Subdomain directory not resolved correcty?

Postby gator » 18. July 2020 18:13

Thanks for the response.
Doublechecked. There is .htaccess in the root dir, which only had 404 and 403 file directives, to be sure emptied .htaccess file out. Same result.
Is there a way to trace/log more info to debug the issue?
gator
 
Posts: 5
Joined: 18. July 2020 03:43
XAMPP version: 3.2.2
Operating System: Windows 10

Re: Subdomain directory not resolved correcty?

Postby Nobbie » 18. July 2020 18:37

I dont know.

Its very strange, due to the error log actually the file cannot be accessed from that VirtualHost. Is there a problem with typos (wrong uppercase/lowercase character, space in filename, missing file extension - whatever)?
Nobbie
 
Posts: 11771
Joined: 09. March 2008 13:04

Re: Subdomain directory not resolved correcty?

Postby gator » 18. July 2020 23:57

Nope, I copy paste base url that works, change to subdomain that doesn't simply cut the word images and paste after mysite.com, filename, etc is all correct as far as I can tell...
Is there anything in httpd.conf that can affect/override vhost?
gator
 
Posts: 5
Joined: 18. July 2020 03:43
XAMPP version: 3.2.2
Operating System: Windows 10

Re: Subdomain directory not resolved correcty? (Resolved!)

Postby gator » 19. July 2020 01:57

Well, very strange things, but in the end happy to have solved it.
The issue was the damn /icons/ in the path, which for whatever reason never affects base url, but messes up for subdomain.
And the offending line below, and the fix was to comment it out
# Alias /icons/ "C:/Dev/xampp/apache/icons/" line in the httpd-autoindex.conf file.

Not quite sure if this is apache bug or not, but as it is, having /icons/ alias in the in the httpd-autoindex.conf file prevent access to any file having /icons/ in the path even in entirely different directory, and that only happens for subdomains, and apparently only on windows, like I said, all that works fine on linux comp.

For more curious minds, a bit more details:

Fired up sysinternals process monitor to watch what files/paths apache was accessing.

For base url this is the sequence which works - http://mysite.com/images/icons/icon1.png, even though alias pattern matches we're still ok
As you can see, apache goes straight for the documentroot as defined in vhost entry for domain
5:19:38.0062720 PM httpd.exe 16008 CreateFile C:\Dev\websrc\mysite SUCCESS
5:19:38.0063788 PM httpd.exe 16008 QueryDirectory C:\Dev\websrc\mysite\images SUCCESS Filter: images, 1: images
5:19:38.0067148 PM httpd.exe 16008 QueryDirectory C:\Dev\websrc\mysite\images\icons SUCCESS Filter: icons, 1: icons
5:19:38.0074451 PM httpd.exe 16008 CreateFile C:\Dev\websrc\mysite\images\icons\icon1.png SUCCESS

For the subdomain url http://images.mysite.com/icons/icon1.png which fails it's different, and never even tries to access c:/dev/websrc/mysite/images dir at all, goes straight for apache's icons alias
4:23:42.8675346 PM httpd.exe 16008 CreateFile C:\ SUCCESS
4:23:42.8675698 PM httpd.exe 16008 QueryDirectory C:\Dev SUCCESS Filter: Dev, 1: Dev
4:23:42.8677299 PM httpd.exe 16008 QueryDirectory C:\Dev\xampp SUCCESS Filter: xampp, 1: xampp
4:23:42.8678990 PM httpd.exe 16008 QueryDirectory C:\Dev\xampp\apache SUCCESS Filter: apache, 1: apache
4:23:42.8680882 PM httpd.exe 16008 QueryDirectory C:\Dev\xampp\apache\icons SUCCESS Filter: icons, 1: icons
4:23:42.8681869 PM httpd.exe 16008 CreateFile C:\Dev\xampp\apache\icons SUCCESS
4:23:42.8683055 PM httpd.exe 16008 CreateFile C:\Dev\xampp\apache\icons\icon1.png PATH NOT FOUND
4:23:42.8690421 PM httpd.exe 16008 QueryDirectory C:\Dev\xampp\apache\icons\* SUCCESS
4:23:42.8690617 PM httpd.exe 16008 QueryDirectory C:\Dev\xampp\apache\icons SUCCESS
gator
 
Posts: 5
Joined: 18. July 2020 03:43
XAMPP version: 3.2.2
Operating System: Windows 10

Re: Subdomain directory not resolved correcty? (Resolved!)

Postby Nobbie » 19. July 2020 11:14

gator wrote:all that works fine on linux comp.


My talking for years - no Windows (and of course no MacOS)! I have been using only Linux for many years....
Nobbie
 
Posts: 11771
Joined: 09. March 2008 13:04

Re: Subdomain directory not resolved correcty? (Resolved!)

Postby Nobbie » 19. July 2020 11:38

Actually, i thought a while about this problem and it is NOT a bug. it dont works differently on linux (with the same configuration of course). I will tell you, why:

gator wrote:For base url this is the sequence which works - http://mysite.com/images/icons/icon1.png, even though alias pattern matches we're still ok


No, the ALIAS is NOT(!) a matching option, the URL must be EQUAL(!) to the first paramater of the ALIAS clause. In this VirtualHost context, the start of the URL is "/images/" and that is NOT EQUAL to /icons/! Therefore the ALIAS becomes not active, instead Apache goes for the DocumenRoot. If you would enter (for example) http://mysite.com/icons/icon1.png, it also would give you an 404, as it relates to C:\Dev\xampp\apache\icons because the ALIAS is defined for the whole Server Environment and thus for all VirtualHosts. Create C:/Dev/websrc/mysite/icons/icon1.jpg and you will see, you CANNOT resolve to it with neither VirtualHost (due to the ALIAS).

gator wrote:For the subdomain url http://images.mysite.com/icons/icon1.png which fails it's different, and never even tries to access c:/dev/websrc/mysite/images dir at all, goes straight for apache's icons alias


And YES, thats exactly what it should do due to the ALIAS!

So everything works "as designed", the problem is simply the ALIAS you overlooked in httpd-autoindex.conf - and your wrong understanding of the ALIAS Paramater, its not a MATCHING URL, it must be EQUAL.
Nobbie
 
Posts: 11771
Joined: 09. March 2008 13:04

Re: Subdomain directory not resolved correcty?

Postby Altrea » 19. July 2020 12:43

Years ago I made a post about all Alias XAMPP had registered (at this time). Many of them if not all are still active

viewtopic.php?f=16&t=68998&p=236503#p236503
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 10428
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Subdomain directory not resolved correcty? (Resolved!)

Postby gator » 19. July 2020 18:28

Nobbie wrote:Actually, i thought a while about this problem and it is NOT a bug. it dont works differently on linux (with the same configuration of course). I will tell you, why:
...
No, the ALIAS is NOT(!) a matching option, the URL must be EQUAL(!) to the first paramater of the ALIAS clause.
..
So everything works "as designed", the problem is simply the ALIAS you overlooked in httpd-autoindex.conf - and your wrong understanding of the ALIAS Paramater, its not a MATCHING URL, it must be EQUAL.

Thanks Nobbie, for the detailed explanation.
I misunderstood how alias worked, 'contains' vs. starts with. And yeah, on the host server linux doesn't have icons alias, which explains why it works there.
gator
 
Posts: 5
Joined: 18. July 2020 03:43
XAMPP version: 3.2.2
Operating System: Windows 10


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 84 guests