Mailing List Archive

conditionally create a Virtual Host?
Greetings,

In my development environment on a Windows 10 PC I have added the following to Apache's configuration files -

To httpd.conf:
Listen 8080

To httpd-vhosts.conf:
<VirtualHost *:8080>
DocumentRoot "Z:/files/xampp/htdocs"
<Directory "Z:/files/xampp/htdocs">
Options Indexes
Require all granted
</Directory>
</VirtualHost>

Note that Z: is mapped to an external storage device.

With this setup, Apache successfully accesses C: on port 80 and Z: on port 8080. However, if the external storage device is not attached to the computer, Apache will not start. Is there a way to check if Z: is present, and only create the virtual host if that device is plugged in so that Apache always starts? If so, how can this be achieved?
Re: conditionally create a Virtual Host? [ In reply to ]
On Wed, Aug 21, 2019 at 8:21 PM Heather Lotz <knot22@hotmail.com> wrote:
>
> Greetings,
>
> In my development environment on a Windows 10 PC I have added the following to Apache's configuration files -
>
> To httpd.conf:
> Listen 8080
>
> To httpd-vhosts.conf:
> <VirtualHost *:8080>
> DocumentRoot "Z:/files/xampp/htdocs"
> <Directory "Z:/files/xampp/htdocs">
> Options Indexes
> Require all granted
> </Directory>
> </VirtualHost>
>
> Note that Z: is mapped to an external storage device.
>
> With this setup, Apache successfully accesses C: on port 80 and Z: on port 8080. However, if the external storage device is not attached to the computer, Apache will not start. Is there a way to check if Z: is present, and only create the virtual host if that device is plugged in so that Apache always starts? If so, how can this be achieved?

Try <IfFile> https://httpd.apache.org/docs/2.4/mod/core.html#iffile

--
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: conditionally create a Virtual Host? [ In reply to ]
A new file was created on Z: for the sole purpose of having a designated file for Apache to seek.
The file is called Z:\files\development\ApacheSmokeSignal.txt.

Here is what httpd-vhosts.conf looks like now:
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
<VirtualHost *:8080>
DocumentRoot "Z:/files/xampp/htdocs"
<Directory "Z:/files/xampp/htdocs">
Options Indexes
Require all granted
</Directory>
</VirtualHost>
</IfFile>

With this update in place, Apache starts fine when Z: is attached to the PC. However, when Z: is not attached to the PC Apache does not start and these lines appear in the XAMPP Control Panel console:
9:30:24 PM [Apache] Attempting to start Apache app...
9:30:24 PM [Apache] Status change detected: running
9:30:26 PM [Apache] Status change detected: stopped
9:30:26 PM [Apache] Error: Apache shutdown unexpectedly.
9:30:26 PM [Apache] This may be due to a blocked port, missing dependencies,
9:30:26 PM [Apache] improper privileges, a crash, or a shutdown by another method.
9:30:26 PM [Apache] Press the Logs button to view error logs and check
9:30:26 PM [Apache] the Windows Event Viewer for more clues
9:30:26 PM [Apache] If you need more help, copy and post this
9:30:26 PM [Apache] entire log window on the forums

There are no entries in error.log with a Wed Aug 21 21:30 or later timestamp.

Is the syntax incorrect? Note that Apache is installed in this location on the PC in question: C:\xampp\apache.

________________________________
From: Eric Covener <covener@gmail.com>
Sent: Wednesday, August 21, 2019 7:27 PM
To: users@httpd.apache.org <users@httpd.apache.org>
Subject: Re: [users@httpd] conditionally create a Virtual Host?

On Wed, Aug 21, 2019 at 8:21 PM Heather Lotz <knot22@hotmail.com> wrote:
>
> Greetings,
>
> In my development environment on a Windows 10 PC I have added the following to Apache's configuration files -
>
> To httpd.conf:
> Listen 8080
>
> To httpd-vhosts.conf:
> <VirtualHost *:8080>
> DocumentRoot "Z:/files/xampp/htdocs"
> <Directory "Z:/files/xampp/htdocs">
> Options Indexes
> Require all granted
> </Directory>
> </VirtualHost>
>
> Note that Z: is mapped to an external storage device.
>
> With this setup, Apache successfully accesses C: on port 80 and Z: on port 8080. However, if the external storage device is not attached to the computer, Apache will not start. Is there a way to check if Z: is present, and only create the virtual host if that device is plugged in so that Apache always starts? If so, how can this be achieved?

Try <IfFile> https://httpd.apache.org/docs/2.4/mod/core.html#iffile

--
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: conditionally create a Virtual Host? [ In reply to ]
On Wed, 21 Aug 2019 at 7:21 pm, Heather Lotz <knot22@hotmail.com> wrote:

> Greetings,
>
> In my development environment on a Windows 10 PC I have added the
> following to Apache's configuration files -
>
> To httpd.conf:
> Listen 8080
>
> To httpd-vhosts.conf:
> <VirtualHost *:8080>
> DocumentRoot "Z:/files/xampp/htdocs"
> <Directory "Z:/files/xampp/htdocs">
> Options Indexes
> Require all granted
> </Directory>
> </VirtualHost>
>
> Note that Z: is mapped to an external storage device.
>
> With this setup, Apache successfully accesses C: on port 80 and Z: on port
> 8080. However, if the external storage device is not attached to the
> computer, Apache will not start. Is there a way to check if Z: is present,
> and only create the virtual host if that device is plugged in so that
> Apache always starts? If so, how can this be achieved?
>
I reckon you could wrap the <VirtualHost> in an<If> that checks for the
existence of z:/ using an appropriate operator from:
https://httpd.apache.org/docs/current/expr.html#unnop

Nigel B. Peck
Web Technologies and Linux Admin Mentor
https://codementor.io/nigelbpeck
Re: conditionally create a Virtual Host? [ In reply to ]
A new file was created on Z: for the sole purpose of having a designated file for Apache to seek.
The file is called Z:\files\development\ApacheSmokeSignal.txt.

The httpd-vhosts.conf file was modified as follows:
<If "-d Z:/files/development/ApacheSmokeSignal.txt">
<VirtualHost *:8080>
DocumentRoot "Z:/files/xampp/htdocs"
<Directory "Z:/files/xampp/htdocs">
Options Indexes
Require all granted
</Directory>
</VirtualHost>
</If>

With this update, Apache starts so long as Z: is attached to the PC. However, when Z: is not attached Apache does not start and these lines appear in the XAMPP Control Panel console:
9:54:20 PM [Apache] Error: Apache shutdown unexpectedly.
9:54:20 PM [Apache] This may be due to a blocked port, missing dependencies,
9:54:20 PM [Apache] improper privileges, a crash, or a shutdown by another method.
9:54:20 PM [Apache] Press the Logs button to view error logs and check
9:54:20 PM [Apache] the Windows Event Viewer for more clues
9:54:20 PM [Apache] If you need more help, copy and post this
9:54:20 PM [Apache] entire log window on the forums

There are no entries in error.log with a Wed Aug 21 21:54 or later timestamp.

Is the syntax for the If tag incorrect or was the wrong unary operator selected?

________________________________
From: Nigel B. Peck <nigelbpeck@gmail.com>
Sent: Wednesday, August 21, 2019 9:45 PM
To: users@httpd.apache.org <users@httpd.apache.org>
Subject: Re: [users@httpd] conditionally create a Virtual Host?

On Wed, 21 Aug 2019 at 7:21 pm, Heather Lotz <knot22@hotmail.com<mailto:knot22@hotmail.com>> wrote:
Greetings,

In my development environment on a Windows 10 PC I have added the following to Apache's configuration files -

To httpd.conf:
Listen 8080

To httpd-vhosts.conf:
<VirtualHost *:8080>
DocumentRoot "Z:/files/xampp/htdocs"
<Directory "Z:/files/xampp/htdocs">
Options Indexes
Require all granted
</Directory>
</VirtualHost>

Note that Z: is mapped to an external storage device.

With this setup, Apache successfully accesses C: on port 80 and Z: on port 8080. However, if the external storage device is not attached to the computer, Apache will not start. Is there a way to check if Z: is present, and only create the virtual host if that device is plugged in so that Apache always starts? If so, how can this be achieved?
I reckon you could wrap the <VirtualHost> in an<If> that checks for the existence of z:/ using an appropriate operator from:
https://httpd.apache.org/docs/current/expr.html#unnop

Nigel B. Peck
Web Technologies and Linux Admin Mentor
https://codementor.io/nigelbpeck
Re: conditionally create a Virtual Host? [ In reply to ]
After some more testing, it seems that this syntax -
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
is the root cause of Apache not starting when the external storage device, mapped to Z:, is detached from the Windows 10 PC.

I tested these variants individually, which are more *nix like -
<IfFile "Z/files/development/ApacheSmokeSignal.txt">
<IfFile "/Z/files/development/ApacheSmokeSignal.txt">
<IfFile "/z/files/development/ApacheSmokeSignal.txt">
and the behavior is Apache starts whether or not Z: is attached to the PC, so that is a step in the right direction. However, the code within the <IfFile> tags never executes because when localhost:8080/miscellaneous/ is entered in a browser it always returns a 404 error.

Another test was this -
<IfFile "/c/Users/heather.lotz/Documents/_user_files/test.txt">
which points to an existing file which is not stored on Z:. The behavior here was the same as that of the 3 *nix like tests. Apache starts whether or not Z: is attached to the PC but code within the <IfFile> tags is not executed because localhost:8080/miscellaneous/ returns a 404 error.

Does this constitute a bug of <IfFile> when used on a Windows OS?

________________________________
From: Heather Lotz <knot22@hotmail.com>
Sent: Wednesday, August 21, 2019 9:36 PM
To: users@httpd.apache.org <users@httpd.apache.org>
Subject: Re: [users@httpd] conditionally create a Virtual Host?

A new file was created on Z: for the sole purpose of having a designated file for Apache to seek.
The file is called Z:\files\development\ApacheSmokeSignal.txt.

Here is what httpd-vhosts.conf looks like now:
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
<VirtualHost *:8080>
DocumentRoot "Z:/files/xampp/htdocs"
<Directory "Z:/files/xampp/htdocs">
Options Indexes
Require all granted
</Directory>
</VirtualHost>
</IfFile>

With this update in place, Apache starts fine when Z: is attached to the PC. However, when Z: is not attached to the PC Apache does not start and these lines appear in the XAMPP Control Panel console:
9:30:24 PM [Apache] Attempting to start Apache app...
9:30:24 PM [Apache] Status change detected: running
9:30:26 PM [Apache] Status change detected: stopped
9:30:26 PM [Apache] Error: Apache shutdown unexpectedly.
9:30:26 PM [Apache] This may be due to a blocked port, missing dependencies,
9:30:26 PM [Apache] improper privileges, a crash, or a shutdown by another method.
9:30:26 PM [Apache] Press the Logs button to view error logs and check
9:30:26 PM [Apache] the Windows Event Viewer for more clues
9:30:26 PM [Apache] If you need more help, copy and post this
9:30:26 PM [Apache] entire log window on the forums

There are no entries in error.log with a Wed Aug 21 21:30 or later timestamp.

Is the syntax incorrect? Note that Apache is installed in this location on the PC in question: C:\xampp\apache.

________________________________
From: Eric Covener <covener@gmail.com>
Sent: Wednesday, August 21, 2019 7:27 PM
To: users@httpd.apache.org <users@httpd.apache.org>
Subject: Re: [users@httpd] conditionally create a Virtual Host?

On Wed, Aug 21, 2019 at 8:21 PM Heather Lotz <knot22@hotmail.com> wrote:
>
> Greetings,
>
> In my development environment on a Windows 10 PC I have added the following to Apache's configuration files -
>
> To httpd.conf:
> Listen 8080
>
> To httpd-vhosts.conf:
> <VirtualHost *:8080>
> DocumentRoot "Z:/files/xampp/htdocs"
> <Directory "Z:/files/xampp/htdocs">
> Options Indexes
> Require all granted
> </Directory>
> </VirtualHost>
>
> Note that Z: is mapped to an external storage device.
>
> With this setup, Apache successfully accesses C: on port 80 and Z: on port 8080. However, if the external storage device is not attached to the computer, Apache will not start. Is there a way to check if Z: is present, and only create the virtual host if that device is plugged in so that Apache always starts? If so, how can this be achieved?

Try <IfFile> https://httpd.apache.org/docs/2.4/mod/core.html#iffile

--
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: conditionally create a Virtual Host? [ In reply to ]
Le 23/08/2019 ? 05:04, Heather Lotz a ?crit?:
> After some more testing, it seems that this syntax -
> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
> is the root cause of Apache not starting when the external storage
> device, mapped to Z:, is detached from the Windows 10 PC.
>
> I tested these variants individually, which are more *nix like -
> <IfFile "Z/files/development/ApacheSmokeSignal.txt">
> <IfFile "/Z/files/development/ApacheSmokeSignal.txt">
> <IfFile "/z/files/development/ApacheSmokeSignal.txt">
> and the behavior is Apache starts whether or not Z: is attached to the
> PC, so that is a step in the right direction.? However, the code
> within the <IfFile> tags never executes because when
> localhost:8080/miscellaneous/ is entered in a browser it always
> returns a 404 error.
>
> Another test was this -
> <IfFile "/c/Users/heather.lotz/Documents/_user_files/test.txt">
> which points to an existing file which is not stored on Z:.? The
> behavior here was the same as that of the 3 *nix like tests. Apache
> starts whether or not Z: is attached to the PC but code within the
> <IfFile> tags is not executed because localhost:8080/miscellaneous/
> returns a 404 error.
>
> Does this constitute a bug of <IfFile> when used on a Windows OS?
>
> ------------------------------------------------------------------------
> *From:* Heather Lotz <knot22@hotmail.com>
> *Sent:* Wednesday, August 21, 2019 9:36 PM
> *To:* users@httpd.apache.org <users@httpd.apache.org>
> *Subject:* Re: [users@httpd] conditionally create a Virtual Host?
> A new file was created on Z: for the sole purpose of having a
> designated file for Apache to seek.
> The file is? called Z:\files\development\ApacheSmokeSignal.txt.
>
> Here is what httpd-vhosts.conf looks like now:
> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
> <VirtualHost *:8080>
> ?DocumentRoot "Z:/files/xampp/htdocs"
> ?<Directory "Z:/files/xampp/htdocs">
> ? Options Indexes
> ? Require all granted
> ?</Directory>
> </VirtualHost>
> </IfFile>
>
> With this update in place, Apache starts fine when Z: is attached to
> the PC.? However, when Z: is not attached to the PC Apache does not
> start and these lines appear in the XAMPP Control Panel console:
> 9:30:24 PM ?[Apache] ?Attempting to start Apache app...
> 9:30:24 PM ?[Apache] ?Status change detected: running
> 9:30:26 PM ?[Apache] ?Status change detected: stopped
> 9:30:26 PM ?[Apache] ?Error: Apache shutdown unexpectedly.
> 9:30:26 PM ?[Apache] ?This may be due to a blocked port, missing
> dependencies,
> 9:30:26 PM ?[Apache] ?improper privileges, a crash, or a shutdown by
> another method.
> 9:30:26 PM ?[Apache] ?Press the Logs button to view error logs and check
> 9:30:26 PM ?[Apache] ?the Windows Event Viewer for more clues
> 9:30:26 PM ?[Apache] ?If you need more help, copy and post this
> 9:30:26 PM ?[Apache] ?entire log window on the forums
>
> There are no entries in error.log with a Wed Aug 21 21:30 or later
> timestamp.
>
> Is the syntax incorrect?? Note that Apache is installed in this
> location on the PC in question:?C:\xampp\apache.
>
> ------------------------------------------------------------------------
> *From:* Eric Covener <covener@gmail.com>
> *Sent:* Wednesday, August 21, 2019 7:27 PM
> *To:* users@httpd.apache.org <users@httpd.apache.org>
> *Subject:* Re: [users@httpd] conditionally create a Virtual Host?
> On Wed, Aug 21, 2019 at 8:21 PM Heather Lotz <knot22@hotmail.com> wrote:
> >
> > Greetings,
> >
> > In my development environment on a Windows 10 PC I have added the
> following to Apache's configuration files -
> >
> > To httpd.conf:
> > Listen 8080
> >
> > To httpd-vhosts.conf:
> > <VirtualHost *:8080>
> >???? DocumentRoot "Z:/files/xampp/htdocs"
> > <Directory "Z:/files/xampp/htdocs">
> >? Options Indexes
> >? Require all granted
> > </Directory>
> > </VirtualHost>
> >
> > Note that Z: is mapped to an external storage device.
> >
> > With this setup, Apache successfully accesses C: on port 80 and Z:
> on port 8080.? However, if the external storage device is not attached
> to the computer, Apache will not start.? Is there a way to check if Z:
> is present, and only create the virtual host if that device is plugged
> in so that Apache always starts?? If so, how can this be achieved?
>
> Try <IfFile> https://httpd.apache.org/docs/2.4/mod/core.html#iffile
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
Hi,


would you have the opportunity to test the attached patch?

The 0 passed to apr_stat looks spurious to me. (but should work)



(Pure speculation)
Also, based on Microsoft doc, could you also try:

<IfFile "\\.\Z:">
...

and
<IfFile "\\.\Z:\">

...


CJ
Re: conditionally create a Virtual Host? [ In reply to ]
Hi,


Ok, if you have little knowledge of C, no need to try to apply the patch.

You would need a compiler, some libraries, set-up the environment,
configure, build, install...


I'll install a Windows binaries and try your configuration. Should be
easy to reproduce.


The syntax you have used is correct (Z:/bla/bla/). AFAIK, the internals
of httpd (the APR library to be precise) already translate the '/'
(Linux style) in '\' (Windows style).


My proposal was just based on information taken from Microsoft doc
(search for "When opening a volume or removable media drive (for
example, a floppy disk drive or flash memory thumb drive), ..."? near
the end of
https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew).
Because, at some point, on Windows, 'CreteFileW()' is called.




Just 2 words on the patch.

When a configuration file is parsed, when a '<IfFile ...>' directive is
found, all lines up to the corresponding </Iffile> are discarded.

To do that the function, we call 'apr_stat()' which gives information on
a file (size, name, dates...). In the specific case, no information is
requested. This is unusual. Usually we ask for size only, or "standard"
information.

The patch just changes the requirement from "do not return anything" to
"return size file only".

However, asking for no information *should still work*. The function
should tell us that the file exists or not, without any details on the
file itself, if found.

My point is that using it this way, is unusual. This could hide a corner
case (read: bug in the APR underlying library)


I've had in my todo list for a long time to setup a test environment for
Windows. It could be a good occasion to do it. Or you could try with the
supplier of a Windows binary (Steffen from Apache lounge is following
closely the project and could be of help). Reproduce the issue with
their binaries and report to issue to them as well.


Finally, I put back the mailing list in copy, should anyone have an
opinion on it

CJ


Le 23/08/2019 ? 14:12, Heather Lotz a ?crit?:
> Also, it would be helpful to know the expected syntax to use in
> <IfFile> once the patch is applied.
>
> For instance, does the patch expect
> <IfFile "/z/files/development/ApacheSmokeSignal.txt">
> and the purpose of the patch is to execute the code within the
> <IfFile> tags?
>
> Or does the patch expect
> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
> and the patch will allow the code within the <IfFile> tags to execute
> as it would on a Linux machine?
>
> I opened the patch file in Notepad++ but don't understand the contents.
>
> ------------------------------------------------------------------------
> *From:* Heather Lotz <knot22@hotmail.com>
> *Sent:* Friday, August 23, 2019 6:44 AM
> *To:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> *Subject:* Re: conditionally create a Virtual Host?
> Hello Christophe - Thank-you for the reply.? Can you please provide
> some instructions about how to apply the patch?
> Heather
>
> ------------------------------------------------------------------------
> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> *Sent:* Friday, August 23, 2019 12:50 AM
> *To:* users@httpd.apache.org <users@httpd.apache.org>; Heather Lotz
> <knot22@hotmail.com>
> *Subject:* Re: conditionally create a Virtual Host?
> Le 23/08/2019 ? 05:04, Heather Lotz a ?crit?:
>> After some more testing, it seems that this syntax -
>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>> is the root cause of Apache not starting when the external storage
>> device, mapped to Z:, is detached from the Windows 10 PC.
>>
>> I tested these variants individually, which are more *nix like -
>> <IfFile "Z/files/development/ApacheSmokeSignal.txt">
>> <IfFile "/Z/files/development/ApacheSmokeSignal.txt">
>> <IfFile "/z/files/development/ApacheSmokeSignal.txt">
>> and the behavior is Apache starts whether or not Z: is attached to
>> the PC, so that is a step in the right direction.? However, the code
>> within the <IfFile> tags never executes because when
>> localhost:8080/miscellaneous/ is entered in a browser it always
>> returns a 404 error.
>>
>> Another test was this -
>> <IfFile "/c/Users/heather.lotz/Documents/_user_files/test.txt">
>> which points to an existing file which is not stored on Z:.? The
>> behavior here was the same as that of the 3 *nix like tests.? Apache
>> starts whether or not Z: is attached to the PC but code within the
>> <IfFile> tags is not executed because localhost:8080/miscellaneous/
>> returns a 404 error.
>>
>> Does this constitute a bug of <IfFile> when used on a Windows OS?
>>
>> ------------------------------------------------------------------------
>> *From:* Heather Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>> *Sent:* Wednesday, August 21, 2019 9:36 PM
>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>
>> *Subject:* Re: [users@httpd] conditionally create a Virtual Host?
>> A new file was created on Z: for the sole purpose of having a
>> designated file for Apache to seek.
>> The file is? called Z:\files\development\ApacheSmokeSignal.txt.
>>
>> Here is what httpd-vhosts.conf looks like now:
>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>> <VirtualHost *:8080>
>> ?DocumentRoot "Z:/files/xampp/htdocs"
>> ?<Directory "Z:/files/xampp/htdocs">
>> ? Options Indexes
>> ? Require all granted
>> ?</Directory>
>> </VirtualHost>
>> </IfFile>
>>
>> With this update in place, Apache starts fine when Z: is attached to
>> the PC.? However, when Z: is not attached to the PC Apache does not
>> start and these lines appear in the XAMPP Control Panel console:
>> 9:30:24 PM ?[Apache] ?Attempting to start Apache app...
>> 9:30:24 PM ?[Apache] ?Status change detected: running
>> 9:30:26 PM ?[Apache] ?Status change detected: stopped
>> 9:30:26 PM ?[Apache] ?Error: Apache shutdown unexpectedly.
>> 9:30:26 PM ?[Apache] ?This may be due to a blocked port, missing
>> dependencies,
>> 9:30:26 PM ?[Apache] ?improper privileges, a crash, or a shutdown by
>> another method.
>> 9:30:26 PM ?[Apache] ?Press the Logs button to view error logs and check
>> 9:30:26 PM ?[Apache] ?the Windows Event Viewer for more clues
>> 9:30:26 PM ?[Apache] ?If you need more help, copy and post this
>> 9:30:26 PM ?[Apache] ?entire log window on the forums
>>
>> There are no entries in error.log with a Wed Aug 21 21:30 or later
>> timestamp.
>>
>> Is the syntax incorrect?? Note that Apache is installed in this
>> location on the PC in question:?C:\xampp\apache.
>>
>> ------------------------------------------------------------------------
>> *From:* Eric Covener <covener@gmail.com> <mailto:covener@gmail.com>
>> *Sent:* Wednesday, August 21, 2019 7:27 PM
>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>
>> *Subject:* Re: [users@httpd] conditionally create a Virtual Host?
>> On Wed, Aug 21, 2019 at 8:21 PM Heather Lotz <knot22@hotmail.com>
>> <mailto:knot22@hotmail.com> wrote:
>> >
>> > Greetings,
>> >
>> > In my development environment on a Windows 10 PC I have added the
>> following to Apache's configuration files -
>> >
>> > To httpd.conf:
>> > Listen 8080
>> >
>> > To httpd-vhosts.conf:
>> > <VirtualHost *:8080>
>> >???? DocumentRoot "Z:/files/xampp/htdocs"
>> > <Directory "Z:/files/xampp/htdocs">
>> >? Options Indexes
>> >? Require all granted
>> > </Directory>
>> > </VirtualHost>
>> >
>> > Note that Z: is mapped to an external storage device.
>> >
>> > With this setup, Apache successfully accesses C: on port 80 and Z:
>> on port 8080.? However, if the external storage device is not
>> attached to the computer, Apache will not start.? Is there a way to
>> check if Z: is present, and only create the virtual host if that
>> device is plugged in so that Apache always starts?? If so, how can
>> this be achieved?
>>
>> Try <IfFile> https://httpd.apache.org/docs/2.4/mod/core.html#iffile
>>
>> --
>> Eric Covener
>> covener@gmail.com <mailto:covener@gmail.com>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> <mailto:users-unsubscribe@httpd.apache.org>
>> For additional commands, e-mail: users-help@httpd.apache.org
>> <mailto:users-help@httpd.apache.org>
>>
> Hi,
>
>
> would you have the opportunity to test the attached patch?
>
> The 0 passed to apr_stat looks spurious to me. (but should work)
>
>
>
> (Pure speculation)
> Also, based on Microsoft doc, could you also try:
>
> <IfFile "\\.\Z:">
> ...
>
> and
> <IfFile "\\.\Z:\">
>
> ...
>
>
> CJ
Re: conditionally create a Virtual Host? [ In reply to ]
Right, I have zero knowledge of C. That would be super if you would be able to replicate the issue in a Windows environment. Admittedly, I don't know what a Windows binary is.

I ran some more tests, based on your suggestion, and also found a couple of links about DOS device paths that proved to be helpful*.

Here are the results -
For each of these Apache would not start:
<IfFile "\\.\Z:">
<IfFile "\\.\Z:\">
<IfFile "\\.\Z:\files\development\ApacheSmokeSignal.txt">
<IfFile "\\.\C:">

For each of these Apache would start whether Z: was connected to the PC or not. However, the code within the <IfFile> tags never executed because localhost:8080/miscellaneous/ always returned a 404 error in the browser.
<IfFile "\\?\Z:">
<IfFile "\\?\Z:\">
<IfFile "\\?\Z:\files\development\ApacheSmokeSignal.txt">
<IfFile "\\?\C:">
<IfFile "\\?\C:\">
<IfFile "\\?\C:\Users\heather.lotz\Documents\_user_files\text.txt">

*For reference, here are links to the useful pages about DOS device paths -
https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats
https://stackoverflow.com/questions/23041983/path-prefixes-and


________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Sent: Friday, August 23, 2019 8:55 AM
To: users@httpd.apache.org <users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?


Hi,


Ok, if you have little knowledge of C, no need to try to apply the patch.

You would need a compiler, some libraries, set-up the environment, configure, build, install...


I'll install a Windows binaries and try your configuration. Should be easy to reproduce.


The syntax you have used is correct (Z:/bla/bla/). AFAIK, the internals of httpd (the APR library to be precise) already translate the '/' (Linux style) in '\' (Windows style).


My proposal was just based on information taken from Microsoft doc (search for "When opening a volume or removable media drive (for example, a floppy disk drive or flash memory thumb drive), ..." near the end of https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew). Because, at some point, on Windows, 'CreteFileW()' is called.




Just 2 words on the patch.

When a configuration file is parsed, when a '<IfFile ...>' directive is found, all lines up to the corresponding </Iffile> are discarded.

To do that the function, we call 'apr_stat()' which gives information on a file (size, name, dates...). In the specific case, no information is requested. This is unusual. Usually we ask for size only, or "standard" information.

The patch just changes the requirement from "do not return anything" to "return size file only".

However, asking for no information *should still work*. The function should tell us that the file exists or not, without any details on the file itself, if found.

My point is that using it this way, is unusual. This could hide a corner case (read: bug in the APR underlying library)


I've had in my todo list for a long time to setup a test environment for Windows. It could be a good occasion to do it. Or you could try with the supplier of a Windows binary (Steffen from Apache lounge is following closely the project and could be of help). Reproduce the issue with their binaries and report to issue to them as well.


Finally, I put back the mailing list in copy, should anyone have an opinion on it

CJ


Le 23/08/2019 ? 14:12, Heather Lotz a ?crit :
Also, it would be helpful to know the expected syntax to use in <IfFile> once the patch is applied.

For instance, does the patch expect
<IfFile "/z/files/development/ApacheSmokeSignal.txt">
and the purpose of the patch is to execute the code within the <IfFile> tags?

Or does the patch expect
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
and the patch will allow the code within the <IfFile> tags to execute as it would on a Linux machine?

I opened the patch file in Notepad++ but don't understand the contents.

________________________________
From: Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Sent: Friday, August 23, 2019 6:44 AM
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Subject: Re: conditionally create a Virtual Host?

Hello Christophe - Thank-you for the reply. Can you please provide some instructions about how to apply the patch?
Heather

________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Sent: Friday, August 23, 2019 12:50 AM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?

Le 23/08/2019 ? 05:04, Heather Lotz a ?crit :
After some more testing, it seems that this syntax -
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
is the root cause of Apache not starting when the external storage device, mapped to Z:, is detached from the Windows 10 PC.

I tested these variants individually, which are more *nix like -
<IfFile "Z/files/development/ApacheSmokeSignal.txt">
<IfFile "/Z/files/development/ApacheSmokeSignal.txt">
<IfFile "/z/files/development/ApacheSmokeSignal.txt">
and the behavior is Apache starts whether or not Z: is attached to the PC, so that is a step in the right direction. However, the code within the <IfFile> tags never executes because when localhost:8080/miscellaneous/ is entered in a browser it always returns a 404 error.

Another test was this -
<IfFile "/c/Users/heather.lotz/Documents/_user_files/test.txt">
which points to an existing file which is not stored on Z:. The behavior here was the same as that of the 3 *nix like tests. Apache starts whether or not Z: is attached to the PC but code within the <IfFile> tags is not executed because localhost:8080/miscellaneous/ returns a 404 error.

Does this constitute a bug of <IfFile> when used on a Windows OS?

________________________________
From: Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Sent: Wednesday, August 21, 2019 9:36 PM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>
Subject: Re: [users@httpd] conditionally create a Virtual Host?

A new file was created on Z: for the sole purpose of having a designated file for Apache to seek.
The file is called Z:\files\development\ApacheSmokeSignal.txt.

Here is what httpd-vhosts.conf looks like now:
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
<VirtualHost *:8080>
DocumentRoot "Z:/files/xampp/htdocs"
<Directory "Z:/files/xampp/htdocs">
Options Indexes
Require all granted
</Directory>
</VirtualHost>
</IfFile>

With this update in place, Apache starts fine when Z: is attached to the PC. However, when Z: is not attached to the PC Apache does not start and these lines appear in the XAMPP Control Panel console:
9:30:24 PM [Apache] Attempting to start Apache app...
9:30:24 PM [Apache] Status change detected: running
9:30:26 PM [Apache] Status change detected: stopped
9:30:26 PM [Apache] Error: Apache shutdown unexpectedly.
9:30:26 PM [Apache] This may be due to a blocked port, missing dependencies,
9:30:26 PM [Apache] improper privileges, a crash, or a shutdown by another method.
9:30:26 PM [Apache] Press the Logs button to view error logs and check
9:30:26 PM [Apache] the Windows Event Viewer for more clues
9:30:26 PM [Apache] If you need more help, copy and post this
9:30:26 PM [Apache] entire log window on the forums

There are no entries in error.log with a Wed Aug 21 21:30 or later timestamp.

Is the syntax incorrect? Note that Apache is installed in this location on the PC in question: C:\xampp\apache.

________________________________
From: Eric Covener <covener@gmail.com><mailto:covener@gmail.com>
Sent: Wednesday, August 21, 2019 7:27 PM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>
Subject: Re: [users@httpd] conditionally create a Virtual Host?

On Wed, Aug 21, 2019 at 8:21 PM Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com> wrote:
>
> Greetings,
>
> In my development environment on a Windows 10 PC I have added the following to Apache's configuration files -
>
> To httpd.conf:
> Listen 8080
>
> To httpd-vhosts.conf:
> <VirtualHost *:8080>
> DocumentRoot "Z:/files/xampp/htdocs"
> <Directory "Z:/files/xampp/htdocs">
> Options Indexes
> Require all granted
> </Directory>
> </VirtualHost>
>
> Note that Z: is mapped to an external storage device.
>
> With this setup, Apache successfully accesses C: on port 80 and Z: on port 8080. However, if the external storage device is not attached to the computer, Apache will not start. Is there a way to check if Z: is present, and only create the virtual host if that device is plugged in so that Apache always starts? If so, how can this be achieved?

Try <IfFile> https://httpd.apache.org/docs/2.4/mod/core.html#iffile

--
Eric Covener
covener@gmail.com<mailto:covener@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org<mailto:users-unsubscribe@httpd.apache.org>
For additional commands, e-mail: users-help@httpd.apache.org<mailto:users-help@httpd.apache.org>


Hi,


would you have the opportunity to test the attached patch?

The 0 passed to apr_stat looks spurious to me. (but should work)



(Pure speculation)
Also, based on Microsoft doc, could you also try:

<IfFile "\\.\Z:">
...

and
<IfFile "\\.\Z:\">

...


CJ
Re: conditionally create a Virtual Host? [ In reply to ]
Hi,

confirmed, using the binaries provided by
https://www.apachelounge.com/download/

CJ

Le 23/08/2019 ? 23:53, Heather Lotz a ?crit?:
> Right, I have zero knowledge of C. That would be super if you would be
> able to replicate the issue in a Windows environment.? Admittedly, I
> don't know what a Windows binary is.
>
> I ran some more tests, based on your suggestion, and also found a
> couple of links about DOS device paths that proved to be helpful*.
>
> Here are the results -
> For each of these Apache would not start:
> <IfFile "\\.\Z:">
> <IfFile "\\.\Z:\">
> <IfFile "\\.\Z:\files\development\ApacheSmokeSignal.txt">
> <IfFile "\\.\C:">
>
> For each of these Apache would start whether Z: was connected to the
> PC or not.? However, the code within the <IfFile> tags never executed
> because localhost:8080/miscellaneous/ always returned a 404 error in
> the browser.
> <IfFile "\\?\Z:">
> <IfFile "\\?\Z:\">
> <IfFile "\\?\Z:\files\development\ApacheSmokeSignal.txt">
> <IfFile "\\?\C:">
> <IfFile "\\?\C:\">
> <IfFile "\\?\C:\Users\heather.lotz\Documents\_user_files\text.txt">
>
> *For reference, here are links to the useful pages about DOS device
> paths -
> https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats
> https://stackoverflow.com/questions/23041983/path-prefixes-and
>
>
> ------------------------------------------------------------------------
> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> *Sent:* Friday, August 23, 2019 8:55 AM
> *To:* users@httpd.apache.org <users@httpd.apache.org>; Heather Lotz
> <knot22@hotmail.com>
> *Subject:* Re: conditionally create a Virtual Host?
>
> Hi,
>
>
> Ok, if you have little knowledge of C, no need to try to apply the patch.
>
> You would need a compiler, some libraries, set-up the environment,
> configure, build, install...
>
>
> I'll install a Windows binaries and try your configuration. Should be
> easy to reproduce.
>
>
> The syntax you have used is correct (Z:/bla/bla/). AFAIK, the
> internals of httpd (the APR library to be precise) already translate
> the '/' (Linux style) in '\' (Windows style).
>
>
> My proposal was just based on information taken from Microsoft doc
> (search for "When opening a volume or removable media drive (for
> example, a floppy disk drive or flash memory thumb drive), ..."? near
> the end of
> https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew).
> Because, at some point, on Windows, 'CreteFileW()' is called.
>
>
>
>
> Just 2 words on the patch.
>
> When a configuration file is parsed, when a '<IfFile ...>' directive
> is found, all lines up to the corresponding </Iffile> are discarded.
>
> To do that the function, we call 'apr_stat()' which gives information
> on a file (size, name, dates...). In the specific case, no information
> is requested. This is unusual. Usually we ask for size only, or
> "standard" information.
>
> The patch just changes the requirement from "do not return anything"
> to "return size file only".
>
> However, asking for no information *should still work*. The function
> should tell us that the file exists or not, without any details on the
> file itself, if found.
>
> My point is that using it this way, is unusual. This could hide a
> corner case (read: bug in the APR underlying library)
>
>
> I've had in my todo list for a long time to setup a test environment
> for Windows. It could be a good occasion to do it. Or you could try
> with the supplier of a Windows binary (Steffen from Apache lounge is
> following closely the project and could be of help). Reproduce the
> issue with their binaries and report to issue to them as well.
>
>
> Finally, I put back the mailing list in copy, should anyone have an
> opinion on it
>
> CJ
>
>
> Le 23/08/2019 ? 14:12, Heather Lotz a ?crit?:
>> Also, it would be helpful to know the expected syntax to use in
>> <IfFile> once the patch is applied.
>>
>> For instance, does the patch expect
>> <IfFile "/z/files/development/ApacheSmokeSignal.txt">
>> and the purpose of the patch is to execute the code within the
>> <IfFile> tags?
>>
>> Or does the patch expect
>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>> and the patch will allow the code within the <IfFile> tags to execute
>> as it would on a Linux machine?
>>
>> I opened the patch file in Notepad++ but don't understand the contents.
>>
>> ------------------------------------------------------------------------
>> *From:* Heather Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>> *Sent:* Friday, August 23, 2019 6:44 AM
>> *To:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> <mailto:christophe.jaillet@wanadoo.fr>
>> *Subject:* Re: conditionally create a Virtual Host?
>> Hello Christophe - Thank-you for the reply.? Can you please provide
>> some instructions about how to apply the patch?
>> Heather
>>
>> ------------------------------------------------------------------------
>> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> <mailto:christophe.jaillet@wanadoo.fr>
>> *Sent:* Friday, August 23, 2019 12:50 AM
>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>; Heather
>> Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>> *Subject:* Re: conditionally create a Virtual Host?
>> Le 23/08/2019 ? 05:04, Heather Lotz a ?crit?:
>>> After some more testing, it seems that this syntax -
>>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>>> is the root cause of Apache not starting when the external storage
>>> device, mapped to Z:, is detached from the Windows 10 PC.
>>>
>>> I tested these variants individually, which are more *nix like -
>>> <IfFile "Z/files/development/ApacheSmokeSignal.txt">
>>> <IfFile "/Z/files/development/ApacheSmokeSignal.txt">
>>> <IfFile "/z/files/development/ApacheSmokeSignal.txt">
>>> and the behavior is Apache starts whether or not Z: is attached to
>>> the PC, so that is a step in the right direction.? However, the code
>>> within the <IfFile> tags never executes because when
>>> localhost:8080/miscellaneous/ is entered in a browser it always
>>> returns a 404 error.
>>>
>>> Another test was this -
>>> <IfFile "/c/Users/heather.lotz/Documents/_user_files/test.txt">
>>> which points to an existing file which is not stored on Z:.? The
>>> behavior here was the same as that of the 3 *nix like tests.? Apache
>>> starts whether or not Z: is attached to the PC but code within the
>>> <IfFile> tags is not executed because localhost:8080/miscellaneous/
>>> returns a 404 error.
>>>
>>> Does this constitute a bug of <IfFile> when used on a Windows OS?
>>>
>>> ------------------------------------------------------------------------
>>> *From:* Heather Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>> *Sent:* Wednesday, August 21, 2019 9:36 PM
>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>
>>> *Subject:* Re: [users@httpd] conditionally create a Virtual Host?
>>> A new file was created on Z: for the sole purpose of having a
>>> designated file for Apache to seek.
>>> The file is? called Z:\files\development\ApacheSmokeSignal.txt.
>>>
>>> Here is what httpd-vhosts.conf looks like now:
>>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>>> <VirtualHost *:8080>
>>> ?DocumentRoot "Z:/files/xampp/htdocs"
>>> ?<Directory "Z:/files/xampp/htdocs">
>>> ? Options Indexes
>>> ? Require all granted
>>> ?</Directory>
>>> </VirtualHost>
>>> </IfFile>
>>>
>>> With this update in place, Apache starts fine when Z: is attached to
>>> the PC. However, when Z: is not attached to the PC Apache does not
>>> start and these lines appear in the XAMPP Control Panel console:
>>> 9:30:24 PM ?[Apache] ?Attempting to start Apache app...
>>> 9:30:24 PM ?[Apache] ?Status change detected: running
>>> 9:30:26 PM ?[Apache] ?Status change detected: stopped
>>> 9:30:26 PM ?[Apache] ?Error: Apache shutdown unexpectedly.
>>> 9:30:26 PM ?[Apache] ?This may be due to a blocked port, missing
>>> dependencies,
>>> 9:30:26 PM ?[Apache] ?improper privileges, a crash, or a shutdown by
>>> another method.
>>> 9:30:26 PM ?[Apache] ?Press the Logs button to view error logs and check
>>> 9:30:26 PM ?[Apache] ?the Windows Event Viewer for more clues
>>> 9:30:26 PM ?[Apache] ?If you need more help, copy and post this
>>> 9:30:26 PM ?[Apache] ?entire log window on the forums
>>>
>>> There are no entries in error.log with a Wed Aug 21 21:30 or later
>>> timestamp.
>>>
>>> Is the syntax incorrect?? Note that Apache is installed in this
>>> location on the PC in question:?C:\xampp\apache.
>>>
>>> ------------------------------------------------------------------------
>>> *From:* Eric Covener <covener@gmail.com> <mailto:covener@gmail.com>
>>> *Sent:* Wednesday, August 21, 2019 7:27 PM
>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>
>>> *Subject:* Re: [users@httpd] conditionally create a Virtual Host?
>>> On Wed, Aug 21, 2019 at 8:21 PM Heather Lotz <knot22@hotmail.com>
>>> <mailto:knot22@hotmail.com> wrote:
>>> >
>>> > Greetings,
>>> >
>>> > In my development environment on a Windows 10 PC I have added the
>>> following to Apache's configuration files -
>>> >
>>> > To httpd.conf:
>>> > Listen 8080
>>> >
>>> > To httpd-vhosts.conf:
>>> > <VirtualHost *:8080>
>>> >???? DocumentRoot "Z:/files/xampp/htdocs"
>>> > <Directory "Z:/files/xampp/htdocs">
>>> >? Options Indexes
>>> >? Require all granted
>>> > </Directory>
>>> > </VirtualHost>
>>> >
>>> > Note that Z: is mapped to an external storage device.
>>> >
>>> > With this setup, Apache successfully accesses C: on port 80 and Z:
>>> on port 8080.? However, if the external storage device is not
>>> attached to the computer, Apache will not start.? Is there a way to
>>> check if Z: is present, and only create the virtual host if that
>>> device is plugged in so that Apache always starts?? If so, how can
>>> this be achieved?
>>>
>>> Try <IfFile> https://httpd.apache.org/docs/2.4/mod/core.html#iffile
>>>
>>> --
>>> Eric Covener
>>> covener@gmail.com <mailto:covener@gmail.com>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>> <mailto:users-unsubscribe@httpd.apache.org>
>>> For additional commands, e-mail: users-help@httpd.apache.org
>>> <mailto:users-help@httpd.apache.org>
>>>
>> Hi,
>>
>>
>> would you have the opportunity to test the attached patch?
>>
>> The 0 passed to apr_stat looks spurious to me. (but should work)
>>
>>
>>
>> (Pure speculation)
>> Also, based on Microsoft doc, could you also try:
>>
>> <IfFile "\\.\Z:">
>> ...
>>
>> and
>> <IfFile "\\.\Z:\">
>>
>> ...
>>
>>
>> CJ
Re: conditionally create a Virtual Host? [ In reply to ]
Seeking clarification - does this mean you were able to reproduce the issue?

________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Sent: Saturday, August 24, 2019 5:18 AM
To: users@httpd.apache.org <users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?

Hi,

confirmed, using the binaries provided by https://www.apachelounge.com/download/

CJ

Le 23/08/2019 ? 23:53, Heather Lotz a ?crit :
Right, I have zero knowledge of C. That would be super if you would be able to replicate the issue in a Windows environment. Admittedly, I don't know what a Windows binary is.

I ran some more tests, based on your suggestion, and also found a couple of links about DOS device paths that proved to be helpful*.

Here are the results -
For each of these Apache would not start:
<IfFile "\\.\Z:">
<IfFile "\\.\Z:\">
<IfFile "\\.\Z:\files\development\ApacheSmokeSignal.txt">
<IfFile "\\.\C:">

For each of these Apache would start whether Z: was connected to the PC or not. However, the code within the <IfFile> tags never executed because localhost:8080/miscellaneous/ always returned a 404 error in the browser.
<IfFile "\\?\Z:">
<IfFile "\\?\Z:\">
<IfFile "\\?\Z:\files\development\ApacheSmokeSignal.txt">
<IfFile "\\?\C:">
<IfFile "\\?\C:\">
<IfFile "\\?\C:\Users\heather.lotz\Documents\_user_files\text.txt">

*For reference, here are links to the useful pages about DOS device paths -
https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats
https://stackoverflow.com/questions/23041983/path-prefixes-and


________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Sent: Friday, August 23, 2019 8:55 AM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?


Hi,


Ok, if you have little knowledge of C, no need to try to apply the patch.

You would need a compiler, some libraries, set-up the environment, configure, build, install...


I'll install a Windows binaries and try your configuration. Should be easy to reproduce.


The syntax you have used is correct (Z:/bla/bla/). AFAIK, the internals of httpd (the APR library to be precise) already translate the '/' (Linux style) in '\' (Windows style).


My proposal was just based on information taken from Microsoft doc (search for "When opening a volume or removable media drive (for example, a floppy disk drive or flash memory thumb drive), ..." near the end of https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew). Because, at some point, on Windows, 'CreteFileW()' is called.




Just 2 words on the patch.

When a configuration file is parsed, when a '<IfFile ...>' directive is found, all lines up to the corresponding </Iffile> are discarded.

To do that the function, we call 'apr_stat()' which gives information on a file (size, name, dates...). In the specific case, no information is requested. This is unusual. Usually we ask for size only, or "standard" information.

The patch just changes the requirement from "do not return anything" to "return size file only".

However, asking for no information *should still work*. The function should tell us that the file exists or not, without any details on the file itself, if found.

My point is that using it this way, is unusual. This could hide a corner case (read: bug in the APR underlying library)


I've had in my todo list for a long time to setup a test environment for Windows. It could be a good occasion to do it. Or you could try with the supplier of a Windows binary (Steffen from Apache lounge is following closely the project and could be of help). Reproduce the issue with their binaries and report to issue to them as well.


Finally, I put back the mailing list in copy, should anyone have an opinion on it

CJ


Le 23/08/2019 ? 14:12, Heather Lotz a ?crit :
Also, it would be helpful to know the expected syntax to use in <IfFile> once the patch is applied.

For instance, does the patch expect
<IfFile "/z/files/development/ApacheSmokeSignal.txt">
and the purpose of the patch is to execute the code within the <IfFile> tags?

Or does the patch expect
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
and the patch will allow the code within the <IfFile> tags to execute as it would on a Linux machine?

I opened the patch file in Notepad++ but don't understand the contents.

________________________________
From: Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Sent: Friday, August 23, 2019 6:44 AM
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Subject: Re: conditionally create a Virtual Host?

Hello Christophe - Thank-you for the reply. Can you please provide some instructions about how to apply the patch?
Heather

________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Sent: Friday, August 23, 2019 12:50 AM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?

Le 23/08/2019 ? 05:04, Heather Lotz a ?crit :
After some more testing, it seems that this syntax -
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
is the root cause of Apache not starting when the external storage device, mapped to Z:, is detached from the Windows 10 PC.

I tested these variants individually, which are more *nix like -
<IfFile "Z/files/development/ApacheSmokeSignal.txt">
<IfFile "/Z/files/development/ApacheSmokeSignal.txt">
<IfFile "/z/files/development/ApacheSmokeSignal.txt">
and the behavior is Apache starts whether or not Z: is attached to the PC, so that is a step in the right direction. However, the code within the <IfFile> tags never executes because when localhost:8080/miscellaneous/ is entered in a browser it always returns a 404 error.

Another test was this -
<IfFile "/c/Users/heather.lotz/Documents/_user_files/test.txt">
which points to an existing file which is not stored on Z:. The behavior here was the same as that of the 3 *nix like tests. Apache starts whether or not Z: is attached to the PC but code within the <IfFile> tags is not executed because localhost:8080/miscellaneous/ returns a 404 error.

Does this constitute a bug of <IfFile> when used on a Windows OS?

________________________________
From: Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Sent: Wednesday, August 21, 2019 9:36 PM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>
Subject: Re: [users@httpd] conditionally create a Virtual Host?

A new file was created on Z: for the sole purpose of having a designated file for Apache to seek.
The file is called Z:\files\development\ApacheSmokeSignal.txt.

Here is what httpd-vhosts.conf looks like now:
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
<VirtualHost *:8080>
DocumentRoot "Z:/files/xampp/htdocs"
<Directory "Z:/files/xampp/htdocs">
Options Indexes
Require all granted
</Directory>
</VirtualHost>
</IfFile>

With this update in place, Apache starts fine when Z: is attached to the PC. However, when Z: is not attached to the PC Apache does not start and these lines appear in the XAMPP Control Panel console:
9:30:24 PM [Apache] Attempting to start Apache app...
9:30:24 PM [Apache] Status change detected: running
9:30:26 PM [Apache] Status change detected: stopped
9:30:26 PM [Apache] Error: Apache shutdown unexpectedly.
9:30:26 PM [Apache] This may be due to a blocked port, missing dependencies,
9:30:26 PM [Apache] improper privileges, a crash, or a shutdown by another method.
9:30:26 PM [Apache] Press the Logs button to view error logs and check
9:30:26 PM [Apache] the Windows Event Viewer for more clues
9:30:26 PM [Apache] If you need more help, copy and post this
9:30:26 PM [Apache] entire log window on the forums

There are no entries in error.log with a Wed Aug 21 21:30 or later timestamp.

Is the syntax incorrect? Note that Apache is installed in this location on the PC in question: C:\xampp\apache.

________________________________
From: Eric Covener <covener@gmail.com><mailto:covener@gmail.com>
Sent: Wednesday, August 21, 2019 7:27 PM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>
Subject: Re: [users@httpd] conditionally create a Virtual Host?

On Wed, Aug 21, 2019 at 8:21 PM Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com> wrote:
>
> Greetings,
>
> In my development environment on a Windows 10 PC I have added the following to Apache's configuration files -
>
> To httpd.conf:
> Listen 8080
>
> To httpd-vhosts.conf:
> <VirtualHost *:8080>
> DocumentRoot "Z:/files/xampp/htdocs"
> <Directory "Z:/files/xampp/htdocs">
> Options Indexes
> Require all granted
> </Directory>
> </VirtualHost>
>
> Note that Z: is mapped to an external storage device.
>
> With this setup, Apache successfully accesses C: on port 80 and Z: on port 8080. However, if the external storage device is not attached to the computer, Apache will not start. Is there a way to check if Z: is present, and only create the virtual host if that device is plugged in so that Apache always starts? If so, how can this be achieved?

Try <IfFile> https://httpd.apache.org/docs/2.4/mod/core.html#iffile

--
Eric Covener
covener@gmail.com<mailto:covener@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org<mailto:users-unsubscribe@httpd.apache.org>
For additional commands, e-mail: users-help@httpd.apache.org<mailto:users-help@httpd.apache.org>


Hi,


would you have the opportunity to test the attached patch?

The 0 passed to apr_stat looks spurious to me. (but should work)



(Pure speculation)
Also, based on Microsoft doc, could you also try:

<IfFile "\\.\Z:">
...

and
<IfFile "\\.\Z:\">

...


CJ
Re: conditionally create a Virtual Host? [ In reply to ]
Hello - Just wondering if there has been any progress made on getting <IfFile> to work for Windows.

________________________________
From: Heather Lotz <knot22@hotmail.com>
Sent: Saturday, August 24, 2019 11:40 AM
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>; users@httpd.apache.org <users@httpd.apache.org>
Subject: Re: conditionally create a Virtual Host?

Seeking clarification - does this mean you were able to reproduce the issue?

________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Sent: Saturday, August 24, 2019 5:18 AM
To: users@httpd.apache.org <users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?

Hi,

confirmed, using the binaries provided by https://www.apachelounge.com/download/

CJ

Le 23/08/2019 ? 23:53, Heather Lotz a ?crit :
Right, I have zero knowledge of C. That would be super if you would be able to replicate the issue in a Windows environment. Admittedly, I don't know what a Windows binary is.

I ran some more tests, based on your suggestion, and also found a couple of links about DOS device paths that proved to be helpful*.

Here are the results -
For each of these Apache would not start:
<IfFile "\\.\Z:">
<IfFile "\\.\Z:\">
<IfFile "\\.\Z:\files\development\ApacheSmokeSignal.txt">
<IfFile "\\.\C:">

For each of these Apache would start whether Z: was connected to the PC or not. However, the code within the <IfFile> tags never executed because localhost:8080/miscellaneous/ always returned a 404 error in the browser.
<IfFile "\\?\Z:">
<IfFile "\\?\Z:\">
<IfFile "\\?\Z:\files\development\ApacheSmokeSignal.txt">
<IfFile "\\?\C:">
<IfFile "\\?\C:\">
<IfFile "\\?\C:\Users\heather.lotz\Documents\_user_files\text.txt">

*For reference, here are links to the useful pages about DOS device paths -
https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats
https://stackoverflow.com/questions/23041983/path-prefixes-and


________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Sent: Friday, August 23, 2019 8:55 AM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?


Hi,


Ok, if you have little knowledge of C, no need to try to apply the patch.

You would need a compiler, some libraries, set-up the environment, configure, build, install...


I'll install a Windows binaries and try your configuration. Should be easy to reproduce.


The syntax you have used is correct (Z:/bla/bla/). AFAIK, the internals of httpd (the APR library to be precise) already translate the '/' (Linux style) in '\' (Windows style).


My proposal was just based on information taken from Microsoft doc (search for "When opening a volume or removable media drive (for example, a floppy disk drive or flash memory thumb drive), ..." near the end of https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew). Because, at some point, on Windows, 'CreteFileW()' is called.




Just 2 words on the patch.

When a configuration file is parsed, when a '<IfFile ...>' directive is found, all lines up to the corresponding </Iffile> are discarded.

To do that the function, we call 'apr_stat()' which gives information on a file (size, name, dates...). In the specific case, no information is requested. This is unusual. Usually we ask for size only, or "standard" information.

The patch just changes the requirement from "do not return anything" to "return size file only".

However, asking for no information *should still work*. The function should tell us that the file exists or not, without any details on the file itself, if found.

My point is that using it this way, is unusual. This could hide a corner case (read: bug in the APR underlying library)


I've had in my todo list for a long time to setup a test environment for Windows. It could be a good occasion to do it. Or you could try with the supplier of a Windows binary (Steffen from Apache lounge is following closely the project and could be of help). Reproduce the issue with their binaries and report to issue to them as well.


Finally, I put back the mailing list in copy, should anyone have an opinion on it

CJ


Le 23/08/2019 ? 14:12, Heather Lotz a ?crit :
Also, it would be helpful to know the expected syntax to use in <IfFile> once the patch is applied.

For instance, does the patch expect
<IfFile "/z/files/development/ApacheSmokeSignal.txt">
and the purpose of the patch is to execute the code within the <IfFile> tags?

Or does the patch expect
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
and the patch will allow the code within the <IfFile> tags to execute as it would on a Linux machine?

I opened the patch file in Notepad++ but don't understand the contents.

________________________________
From: Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Sent: Friday, August 23, 2019 6:44 AM
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Subject: Re: conditionally create a Virtual Host?

Hello Christophe - Thank-you for the reply. Can you please provide some instructions about how to apply the patch?
Heather

________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Sent: Friday, August 23, 2019 12:50 AM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?

Le 23/08/2019 ? 05:04, Heather Lotz a ?crit :
After some more testing, it seems that this syntax -
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
is the root cause of Apache not starting when the external storage device, mapped to Z:, is detached from the Windows 10 PC.

I tested these variants individually, which are more *nix like -
<IfFile "Z/files/development/ApacheSmokeSignal.txt">
<IfFile "/Z/files/development/ApacheSmokeSignal.txt">
<IfFile "/z/files/development/ApacheSmokeSignal.txt">
and the behavior is Apache starts whether or not Z: is attached to the PC, so that is a step in the right direction. However, the code within the <IfFile> tags never executes because when localhost:8080/miscellaneous/ is entered in a browser it always returns a 404 error.

Another test was this -
<IfFile "/c/Users/heather.lotz/Documents/_user_files/test.txt">
which points to an existing file which is not stored on Z:. The behavior here was the same as that of the 3 *nix like tests. Apache starts whether or not Z: is attached to the PC but code within the <IfFile> tags is not executed because localhost:8080/miscellaneous/ returns a 404 error.

Does this constitute a bug of <IfFile> when used on a Windows OS?

________________________________
From: Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Sent: Wednesday, August 21, 2019 9:36 PM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>
Subject: Re: [users@httpd] conditionally create a Virtual Host?

A new file was created on Z: for the sole purpose of having a designated file for Apache to seek.
The file is called Z:\files\development\ApacheSmokeSignal.txt.

Here is what httpd-vhosts.conf looks like now:
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
<VirtualHost *:8080>
DocumentRoot "Z:/files/xampp/htdocs"
<Directory "Z:/files/xampp/htdocs">
Options Indexes
Require all granted
</Directory>
</VirtualHost>
</IfFile>

With this update in place, Apache starts fine when Z: is attached to the PC. However, when Z: is not attached to the PC Apache does not start and these lines appear in the XAMPP Control Panel console:
9:30:24 PM [Apache] Attempting to start Apache app...
9:30:24 PM [Apache] Status change detected: running
9:30:26 PM [Apache] Status change detected: stopped
9:30:26 PM [Apache] Error: Apache shutdown unexpectedly.
9:30:26 PM [Apache] This may be due to a blocked port, missing dependencies,
9:30:26 PM [Apache] improper privileges, a crash, or a shutdown by another method.
9:30:26 PM [Apache] Press the Logs button to view error logs and check
9:30:26 PM [Apache] the Windows Event Viewer for more clues
9:30:26 PM [Apache] If you need more help, copy and post this
9:30:26 PM [Apache] entire log window on the forums

There are no entries in error.log with a Wed Aug 21 21:30 or later timestamp.

Is the syntax incorrect? Note that Apache is installed in this location on the PC in question: C:\xampp\apache.

________________________________
From: Eric Covener <covener@gmail.com><mailto:covener@gmail.com>
Sent: Wednesday, August 21, 2019 7:27 PM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>
Subject: Re: [users@httpd] conditionally create a Virtual Host?

On Wed, Aug 21, 2019 at 8:21 PM Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com> wrote:
>
> Greetings,
>
> In my development environment on a Windows 10 PC I have added the following to Apache's configuration files -
>
> To httpd.conf:
> Listen 8080
>
> To httpd-vhosts.conf:
> <VirtualHost *:8080>
> DocumentRoot "Z:/files/xampp/htdocs"
> <Directory "Z:/files/xampp/htdocs">
> Options Indexes
> Require all granted
> </Directory>
> </VirtualHost>
>
> Note that Z: is mapped to an external storage device.
>
> With this setup, Apache successfully accesses C: on port 80 and Z: on port 8080. However, if the external storage device is not attached to the computer, Apache will not start. Is there a way to check if Z: is present, and only create the virtual host if that device is plugged in so that Apache always starts? If so, how can this be achieved?

Try <IfFile> https://httpd.apache.org/docs/2.4/mod/core.html#iffile

--
Eric Covener
covener@gmail.com<mailto:covener@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org<mailto:users-unsubscribe@httpd.apache.org>
For additional commands, e-mail: users-help@httpd.apache.org<mailto:users-help@httpd.apache.org>


Hi,


would you have the opportunity to test the attached patch?

The 0 passed to apr_stat looks spurious to me. (but should work)



(Pure speculation)
Also, based on Microsoft doc, could you also try:

<IfFile "\\.\Z:">
...

and
<IfFile "\\.\Z:\">

...


CJ
Re: conditionally create a Virtual Host? [ In reply to ]
Hi,

I've just got time to set up a build environment for Windows and have
httpd get compiled there (for not without mod_ssl but that's another story)
So now I'm ready for tracking down this strange behavior.

I hope to have time in the coming days to have a look at it.

CJ

Le 01/09/2019 ? 01:11, Heather Lotz a ?crit?:
> Hello - Just wondering if there has been any progress made on getting
> <IfFile> to work for Windows.
>
> ------------------------------------------------------------------------
> *From:* Heather Lotz <knot22@hotmail.com>
> *Sent:* Saturday, August 24, 2019 11:40 AM
> *To:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>;
> users@httpd.apache.org <users@httpd.apache.org>
> *Subject:* Re: conditionally create a Virtual Host?
> Seeking clarification - does this mean you were able to reproduce the
> issue?
>
> ------------------------------------------------------------------------
> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> *Sent:* Saturday, August 24, 2019 5:18 AM
> *To:* users@httpd.apache.org <users@httpd.apache.org>; Heather Lotz
> <knot22@hotmail.com>
> *Subject:* Re: conditionally create a Virtual Host?
> Hi,
>
> confirmed, using the binaries provided by
> https://www.apachelounge.com/download/
> <https://www.apachelounge.com/download/>
>
> CJ
>
> Le 23/08/2019 ? 23:53, Heather Lotz a ?crit?:
>> Right, I have zero knowledge of C. That would be super if you would
>> be able to replicate the issue in a Windows environment.? Admittedly,
>> I don't know what a Windows binary is.
>>
>> I ran some more tests, based on your suggestion, and also found a
>> couple of links about DOS device paths that proved to be helpful*.
>>
>> Here are the results -
>> For each of these Apache would not start:
>> <IfFile "\\.\Z:">
>> <IfFile "\\.\Z:\">
>> <IfFile "\\.\Z:\files\development\ApacheSmokeSignal.txt">
>> <IfFile "\\.\C:">
>>
>> For each of these Apache would start whether Z: was connected to the
>> PC or not.? However, the code within the <IfFile> tags never executed
>> because localhost:8080/miscellaneous/ always returned a 404 error in
>> the browser.
>> <IfFile "\\?\Z:">
>> <IfFile "\\?\Z:\">
>> <IfFile "\\?\Z:\files\development\ApacheSmokeSignal.txt">
>> <IfFile "\\?\C:">
>> <IfFile "\\?\C:\">
>> <IfFile "\\?\C:\Users\heather.lotz\Documents\_user_files\text.txt">
>>
>> *For reference, here are links to the useful pages about DOS device
>> paths -
>> https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats
>> https://stackoverflow.com/questions/23041983/path-prefixes-and
>>
>>
>> ------------------------------------------------------------------------
>> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> <mailto:christophe.jaillet@wanadoo.fr>
>> *Sent:* Friday, August 23, 2019 8:55 AM
>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>; Heather
>> Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>> *Subject:* Re: conditionally create a Virtual Host?
>>
>> Hi,
>>
>>
>> Ok, if you have little knowledge of C, no need to try to apply the patch.
>>
>> You would need a compiler, some libraries, set-up the environment,
>> configure, build, install...
>>
>>
>> I'll install a Windows binaries and try your configuration. Should be
>> easy to reproduce.
>>
>>
>> The syntax you have used is correct (Z:/bla/bla/). AFAIK, the
>> internals of httpd (the APR library to be precise) already translate
>> the '/' (Linux style) in '\' (Windows style).
>>
>>
>> My proposal was just based on information taken from Microsoft doc
>> (search for "When opening a volume or removable media drive (for
>> example, a floppy disk drive or flash memory thumb drive), ..."? near
>> the end of
>> https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew).
>> Because, at some point, on Windows, 'CreteFileW()' is called.
>>
>>
>>
>>
>> Just 2 words on the patch.
>>
>> When a configuration file is parsed, when a '<IfFile ...>' directive
>> is found, all lines up to the corresponding </Iffile> are discarded.
>>
>> To do that the function, we call 'apr_stat()' which gives information
>> on a file (size, name, dates...). In the specific case, no
>> information is requested. This is unusual. Usually we ask for size
>> only, or "standard" information.
>>
>> The patch just changes the requirement from "do not return anything"
>> to "return size file only".
>>
>> However, asking for no information *should still work*. The function
>> should tell us that the file exists or not, without any details on
>> the file itself, if found.
>>
>> My point is that using it this way, is unusual. This could hide a
>> corner case (read: bug in the APR underlying library)
>>
>>
>> I've had in my todo list for a long time to setup a test environment
>> for Windows. It could be a good occasion to do it. Or you could try
>> with the supplier of a Windows binary (Steffen from Apache lounge is
>> following closely the project and could be of help). Reproduce the
>> issue with their binaries and report to issue to them as well.
>>
>>
>> Finally, I put back the mailing list in copy, should anyone have an
>> opinion on it
>>
>> CJ
>>
>>
>> Le 23/08/2019 ? 14:12, Heather Lotz a ?crit?:
>>> Also, it would be helpful to know the expected syntax to use in
>>> <IfFile> once the patch is applied.
>>>
>>> For instance, does the patch expect
>>> <IfFile "/z/files/development/ApacheSmokeSignal.txt">
>>> and the purpose of the patch is to execute the code within the
>>> <IfFile> tags?
>>>
>>> Or does the patch expect
>>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>>> and the patch will allow the code within the <IfFile> tags to
>>> execute as it would on a Linux machine?
>>>
>>> I opened the patch file in Notepad++ but don't understand the contents.
>>>
>>> ------------------------------------------------------------------------
>>> *From:* Heather Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>> *Sent:* Friday, August 23, 2019 6:44 AM
>>> *To:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>> <mailto:christophe.jaillet@wanadoo.fr>
>>> *Subject:* Re: conditionally create a Virtual Host?
>>> Hello Christophe - Thank-you for the reply. Can you please provide
>>> some instructions about how to apply the patch?
>>> Heather
>>>
>>> ------------------------------------------------------------------------
>>> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>> <mailto:christophe.jaillet@wanadoo.fr>
>>> *Sent:* Friday, August 23, 2019 12:50 AM
>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>; Heather
>>> Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>> *Subject:* Re: conditionally create a Virtual Host?
>>> Le 23/08/2019 ? 05:04, Heather Lotz a ?crit?:
>>>> After some more testing, it seems that this syntax -
>>>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>>>> is the root cause of Apache not starting when the external storage
>>>> device, mapped to Z:, is detached from the Windows 10 PC.
>>>>
>>>> I tested these variants individually, which are more *nix like -
>>>> <IfFile "Z/files/development/ApacheSmokeSignal.txt">
>>>> <IfFile "/Z/files/development/ApacheSmokeSignal.txt">
>>>> <IfFile "/z/files/development/ApacheSmokeSignal.txt">
>>>> and the behavior is Apache starts whether or not Z: is attached to
>>>> the PC, so that is a step in the right direction.? However, the
>>>> code within the <IfFile> tags never executes because when
>>>> localhost:8080/miscellaneous/ is entered in a browser it always
>>>> returns a 404 error.
>>>>
>>>> Another test was this -
>>>> <IfFile "/c/Users/heather.lotz/Documents/_user_files/test.txt">
>>>> which points to an existing file which is not stored on Z:.? The
>>>> behavior here was the same as that of the 3 *nix like tests.?
>>>> Apache starts whether or not Z: is attached to the PC but code
>>>> within the <IfFile> tags is not executed because
>>>> localhost:8080/miscellaneous/ returns a 404 error.
>>>>
>>>> Does this constitute a bug of <IfFile> when used on a Windows OS?
>>>>
>>>> ------------------------------------------------------------------------
>>>> *From:* Heather Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>>> *Sent:* Wednesday, August 21, 2019 9:36 PM
>>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>
>>>> *Subject:* Re: [users@httpd] conditionally create a Virtual Host?
>>>> A new file was created on Z: for the sole purpose of having a
>>>> designated file for Apache to seek.
>>>> The file is? called Z:\files\development\ApacheSmokeSignal.txt.
>>>>
>>>> Here is what httpd-vhosts.conf looks like now:
>>>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>>>> <VirtualHost *:8080>
>>>> ?DocumentRoot "Z:/files/xampp/htdocs"
>>>> ?<Directory "Z:/files/xampp/htdocs">
>>>> ? Options Indexes
>>>> ? Require all granted
>>>> ?</Directory>
>>>> </VirtualHost>
>>>> </IfFile>
>>>>
>>>> With this update in place, Apache starts fine when Z: is attached
>>>> to the PC.? However, when Z: is not attached to the PC Apache does
>>>> not start and these lines appear in the XAMPP Control Panel console:
>>>> 9:30:24 PM ?[Apache] ?Attempting to start Apache app...
>>>> 9:30:24 PM ?[Apache] ?Status change detected: running
>>>> 9:30:26 PM ?[Apache] ?Status change detected: stopped
>>>> 9:30:26 PM ?[Apache] ?Error: Apache shutdown unexpectedly.
>>>> 9:30:26 PM ?[Apache] ?This may be due to a blocked port, missing
>>>> dependencies,
>>>> 9:30:26 PM ?[Apache] ?improper privileges, a crash, or a shutdown
>>>> by another method.
>>>> 9:30:26 PM ?[Apache] ?Press the Logs button to view error logs and
>>>> check
>>>> 9:30:26 PM ?[Apache] ?the Windows Event Viewer for more clues
>>>> 9:30:26 PM ?[Apache] ?If you need more help, copy and post this
>>>> 9:30:26 PM ?[Apache] ?entire log window on the forums
>>>>
>>>> There are no entries in error.log with a Wed Aug 21 21:30 or later
>>>> timestamp.
>>>>
>>>> Is the syntax incorrect?? Note that Apache is installed in this
>>>> location on the PC in question:?C:\xampp\apache.
>>>>
>>>> ------------------------------------------------------------------------
>>>> *From:* Eric Covener <covener@gmail.com> <mailto:covener@gmail.com>
>>>> *Sent:* Wednesday, August 21, 2019 7:27 PM
>>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>
>>>> *Subject:* Re: [users@httpd] conditionally create a Virtual Host?
>>>> On Wed, Aug 21, 2019 at 8:21 PM Heather Lotz <knot22@hotmail.com>
>>>> <mailto:knot22@hotmail.com> wrote:
>>>> >
>>>> > Greetings,
>>>> >
>>>> > In my development environment on a Windows 10 PC I have added the
>>>> following to Apache's configuration files -
>>>> >
>>>> > To httpd.conf:
>>>> > Listen 8080
>>>> >
>>>> > To httpd-vhosts.conf:
>>>> > <VirtualHost *:8080>
>>>> >???? DocumentRoot "Z:/files/xampp/htdocs"
>>>> > <Directory "Z:/files/xampp/htdocs">
>>>> >? Options Indexes
>>>> >? Require all granted
>>>> > </Directory>
>>>> > </VirtualHost>
>>>> >
>>>> > Note that Z: is mapped to an external storage device.
>>>> >
>>>> > With this setup, Apache successfully accesses C: on port 80 and
>>>> Z: on port 8080.? However, if the external storage device is not
>>>> attached to the computer, Apache will not start.? Is there a way to
>>>> check if Z: is present, and only create the virtual host if that
>>>> device is plugged in so that Apache always starts?? If so, how can
>>>> this be achieved?
>>>>
>>>> Try <IfFile> https://httpd.apache.org/docs/2.4/mod/core.html#iffile
>>>>
>>>> --
>>>> Eric Covener
>>>> covener@gmail.com <mailto:covener@gmail.com>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>> <mailto:users-unsubscribe@httpd.apache.org>
>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>> <mailto:users-help@httpd.apache.org>
>>>>
>>> Hi,
>>>
>>>
>>> would you have the opportunity to test the attached patch?
>>>
>>> The 0 passed to apr_stat looks spurious to me. (but should work)
>>>
>>>
>>>
>>> (Pure speculation)
>>> Also, based on Microsoft doc, could you also try:
>>>
>>> <IfFile "\\.\Z:">
>>> ...
>>>
>>> and
>>> <IfFile "\\.\Z:\">
>>>
>>> ...
>>>
>>>
>>> CJ
>
>
Re: conditionally create a Virtual Host? [ In reply to ]
Hi,

The issue has been tracked down and has been fixed on trunk in r1866418 [1].

It will be proposed for backport and should be in next release if the
change is approved.

Best regards,
CJ

[1]: http://svn.apache.org/viewvc?rev=1866418&view=rev


Le 01/09/2019 ? 01:11, Heather Lotz a ?crit?:
> Hello - Just wondering if there has been any progress made on getting
> <IfFile> to work for Windows.
>
> ------------------------------------------------------------------------
> *From:* Heather Lotz <knot22@hotmail.com>
> *Sent:* Saturday, August 24, 2019 11:40 AM
> *To:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>;
> users@httpd.apache.org <users@httpd.apache.org>
> *Subject:* Re: conditionally create a Virtual Host?
> Seeking clarification - does this mean you were able to reproduce the
> issue?
>
> ------------------------------------------------------------------------
> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> *Sent:* Saturday, August 24, 2019 5:18 AM
> *To:* users@httpd.apache.org <users@httpd.apache.org>; Heather Lotz
> <knot22@hotmail.com>
> *Subject:* Re: conditionally create a Virtual Host?
> Hi,
>
> confirmed, using the binaries provided by
> https://www.apachelounge.com/download/
> <https://www.apachelounge.com/download/>
>
> CJ
>
> Le 23/08/2019 ? 23:53, Heather Lotz a ?crit?:
>> Right, I have zero knowledge of C. That would be super if you would
>> be able to replicate the issue in a Windows environment.? Admittedly,
>> I don't know what a Windows binary is.
>>
>> I ran some more tests, based on your suggestion, and also found a
>> couple of links about DOS device paths that proved to be helpful*.
>>
>> Here are the results -
>> For each of these Apache would not start:
>> <IfFile "\\.\Z:">
>> <IfFile "\\.\Z:\">
>> <IfFile "\\.\Z:\files\development\ApacheSmokeSignal.txt">
>> <IfFile "\\.\C:">
>>
>> For each of these Apache would start whether Z: was connected to the
>> PC or not.? However, the code within the <IfFile> tags never executed
>> because localhost:8080/miscellaneous/ always returned a 404 error in
>> the browser.
>> <IfFile "\\?\Z:">
>> <IfFile "\\?\Z:\">
>> <IfFile "\\?\Z:\files\development\ApacheSmokeSignal.txt">
>> <IfFile "\\?\C:">
>> <IfFile "\\?\C:\">
>> <IfFile "\\?\C:\Users\heather.lotz\Documents\_user_files\text.txt">
>>
>> *For reference, here are links to the useful pages about DOS device
>> paths -
>> https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats
>> https://stackoverflow.com/questions/23041983/path-prefixes-and
>>
>>
>> ------------------------------------------------------------------------
>> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> <mailto:christophe.jaillet@wanadoo.fr>
>> *Sent:* Friday, August 23, 2019 8:55 AM
>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>; Heather
>> Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>> *Subject:* Re: conditionally create a Virtual Host?
>>
>> Hi,
>>
>>
>> Ok, if you have little knowledge of C, no need to try to apply the patch.
>>
>> You would need a compiler, some libraries, set-up the environment,
>> configure, build, install...
>>
>>
>> I'll install a Windows binaries and try your configuration. Should be
>> easy to reproduce.
>>
>>
>> The syntax you have used is correct (Z:/bla/bla/). AFAIK, the
>> internals of httpd (the APR library to be precise) already translate
>> the '/' (Linux style) in '\' (Windows style).
>>
>>
>> My proposal was just based on information taken from Microsoft doc
>> (search for "When opening a volume or removable media drive (for
>> example, a floppy disk drive or flash memory thumb drive), ..."? near
>> the end of
>> https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew).
>> Because, at some point, on Windows, 'CreteFileW()' is called.
>>
>>
>>
>>
>> Just 2 words on the patch.
>>
>> When a configuration file is parsed, when a '<IfFile ...>' directive
>> is found, all lines up to the corresponding </Iffile> are discarded.
>>
>> To do that the function, we call 'apr_stat()' which gives information
>> on a file (size, name, dates...). In the specific case, no
>> information is requested. This is unusual. Usually we ask for size
>> only, or "standard" information.
>>
>> The patch just changes the requirement from "do not return anything"
>> to "return size file only".
>>
>> However, asking for no information *should still work*. The function
>> should tell us that the file exists or not, without any details on
>> the file itself, if found.
>>
>> My point is that using it this way, is unusual. This could hide a
>> corner case (read: bug in the APR underlying library)
>>
>>
>> I've had in my todo list for a long time to setup a test environment
>> for Windows. It could be a good occasion to do it. Or you could try
>> with the supplier of a Windows binary (Steffen from Apache lounge is
>> following closely the project and could be of help). Reproduce the
>> issue with their binaries and report to issue to them as well.
>>
>>
>> Finally, I put back the mailing list in copy, should anyone have an
>> opinion on it
>>
>> CJ
>>
>>
>> Le 23/08/2019 ? 14:12, Heather Lotz a ?crit?:
>>> Also, it would be helpful to know the expected syntax to use in
>>> <IfFile> once the patch is applied.
>>>
>>> For instance, does the patch expect
>>> <IfFile "/z/files/development/ApacheSmokeSignal.txt">
>>> and the purpose of the patch is to execute the code within the
>>> <IfFile> tags?
>>>
>>> Or does the patch expect
>>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>>> and the patch will allow the code within the <IfFile> tags to
>>> execute as it would on a Linux machine?
>>>
>>> I opened the patch file in Notepad++ but don't understand the contents.
>>>
>>> ------------------------------------------------------------------------
>>> *From:* Heather Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>> *Sent:* Friday, August 23, 2019 6:44 AM
>>> *To:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>> <mailto:christophe.jaillet@wanadoo.fr>
>>> *Subject:* Re: conditionally create a Virtual Host?
>>> Hello Christophe - Thank-you for the reply. Can you please provide
>>> some instructions about how to apply the patch?
>>> Heather
>>>
>>> ------------------------------------------------------------------------
>>> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>> <mailto:christophe.jaillet@wanadoo.fr>
>>> *Sent:* Friday, August 23, 2019 12:50 AM
>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>; Heather
>>> Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>> *Subject:* Re: conditionally create a Virtual Host?
>>> Le 23/08/2019 ? 05:04, Heather Lotz a ?crit?:
>>>> After some more testing, it seems that this syntax -
>>>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>>>> is the root cause of Apache not starting when the external storage
>>>> device, mapped to Z:, is detached from the Windows 10 PC.
>>>>
>>>> I tested these variants individually, which are more *nix like -
>>>> <IfFile "Z/files/development/ApacheSmokeSignal.txt">
>>>> <IfFile "/Z/files/development/ApacheSmokeSignal.txt">
>>>> <IfFile "/z/files/development/ApacheSmokeSignal.txt">
>>>> and the behavior is Apache starts whether or not Z: is attached to
>>>> the PC, so that is a step in the right direction.? However, the
>>>> code within the <IfFile> tags never executes because when
>>>> localhost:8080/miscellaneous/ is entered in a browser it always
>>>> returns a 404 error.
>>>>
>>>> Another test was this -
>>>> <IfFile "/c/Users/heather.lotz/Documents/_user_files/test.txt">
>>>> which points to an existing file which is not stored on Z:.? The
>>>> behavior here was the same as that of the 3 *nix like tests.?
>>>> Apache starts whether or not Z: is attached to the PC but code
>>>> within the <IfFile> tags is not executed because
>>>> localhost:8080/miscellaneous/ returns a 404 error.
>>>>
>>>> Does this constitute a bug of <IfFile> when used on a Windows OS?
>>>>
>>>> ------------------------------------------------------------------------
>>>> *From:* Heather Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>>> *Sent:* Wednesday, August 21, 2019 9:36 PM
>>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>
>>>> *Subject:* Re: [users@httpd] conditionally create a Virtual Host?
>>>> A new file was created on Z: for the sole purpose of having a
>>>> designated file for Apache to seek.
>>>> The file is? called Z:\files\development\ApacheSmokeSignal.txt.
>>>>
>>>> Here is what httpd-vhosts.conf looks like now:
>>>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>>>> <VirtualHost *:8080>
>>>> ?DocumentRoot "Z:/files/xampp/htdocs"
>>>> ?<Directory "Z:/files/xampp/htdocs">
>>>> ? Options Indexes
>>>> ? Require all granted
>>>> ?</Directory>
>>>> </VirtualHost>
>>>> </IfFile>
>>>>
>>>> With this update in place, Apache starts fine when Z: is attached
>>>> to the PC.? However, when Z: is not attached to the PC Apache does
>>>> not start and these lines appear in the XAMPP Control Panel console:
>>>> 9:30:24 PM ?[Apache] ?Attempting to start Apache app...
>>>> 9:30:24 PM ?[Apache] ?Status change detected: running
>>>> 9:30:26 PM ?[Apache] ?Status change detected: stopped
>>>> 9:30:26 PM ?[Apache] ?Error: Apache shutdown unexpectedly.
>>>> 9:30:26 PM ?[Apache] ?This may be due to a blocked port, missing
>>>> dependencies,
>>>> 9:30:26 PM ?[Apache] ?improper privileges, a crash, or a shutdown
>>>> by another method.
>>>> 9:30:26 PM ?[Apache] ?Press the Logs button to view error logs and
>>>> check
>>>> 9:30:26 PM ?[Apache] ?the Windows Event Viewer for more clues
>>>> 9:30:26 PM ?[Apache] ?If you need more help, copy and post this
>>>> 9:30:26 PM ?[Apache] ?entire log window on the forums
>>>>
>>>> There are no entries in error.log with a Wed Aug 21 21:30 or later
>>>> timestamp.
>>>>
>>>> Is the syntax incorrect?? Note that Apache is installed in this
>>>> location on the PC in question:?C:\xampp\apache.
>>>>
>>>> ------------------------------------------------------------------------
>>>> *From:* Eric Covener <covener@gmail.com> <mailto:covener@gmail.com>
>>>> *Sent:* Wednesday, August 21, 2019 7:27 PM
>>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>
>>>> *Subject:* Re: [users@httpd] conditionally create a Virtual Host?
>>>> On Wed, Aug 21, 2019 at 8:21 PM Heather Lotz <knot22@hotmail.com>
>>>> <mailto:knot22@hotmail.com> wrote:
>>>> >
>>>> > Greetings,
>>>> >
>>>> > In my development environment on a Windows 10 PC I have added the
>>>> following to Apache's configuration files -
>>>> >
>>>> > To httpd.conf:
>>>> > Listen 8080
>>>> >
>>>> > To httpd-vhosts.conf:
>>>> > <VirtualHost *:8080>
>>>> >???? DocumentRoot "Z:/files/xampp/htdocs"
>>>> > <Directory "Z:/files/xampp/htdocs">
>>>> >? Options Indexes
>>>> >? Require all granted
>>>> > </Directory>
>>>> > </VirtualHost>
>>>> >
>>>> > Note that Z: is mapped to an external storage device.
>>>> >
>>>> > With this setup, Apache successfully accesses C: on port 80 and
>>>> Z: on port 8080.? However, if the external storage device is not
>>>> attached to the computer, Apache will not start.? Is there a way to
>>>> check if Z: is present, and only create the virtual host if that
>>>> device is plugged in so that Apache always starts?? If so, how can
>>>> this be achieved?
>>>>
>>>> Try <IfFile> https://httpd.apache.org/docs/2.4/mod/core.html#iffile
>>>>
>>>> --
>>>> Eric Covener
>>>> covener@gmail.com <mailto:covener@gmail.com>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>> <mailto:users-unsubscribe@httpd.apache.org>
>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>> <mailto:users-help@httpd.apache.org>
>>>>
>>> Hi,
>>>
>>>
>>> would you have the opportunity to test the attached patch?
>>>
>>> The 0 passed to apr_stat looks spurious to me. (but should work)
>>>
>>>
>>>
>>> (Pure speculation)
>>> Also, based on Microsoft doc, could you also try:
>>>
>>> <IfFile "\\.\Z:">
>>> ...
>>>
>>> and
>>> <IfFile "\\.\Z:\">
>>>
>>> ...
>>>
>>>
>>> CJ
>
>
Re: conditionally create a Virtual Host? [ In reply to ]
That is fantastic news! Thank-you very much for figuring it out and fixing it. Assuming the change gets approved, approximately when will the next release become available?

________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Sent: Wednesday, September 4, 2019 2:14 PM
To: users@httpd.apache.org <users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?

Hi,

The issue has been tracked down and has been fixed on trunk in r1866418 [1].

It will be proposed for backport and should be in next release if the change is approved.

Best regards,
CJ

[1]: http://svn.apache.org/viewvc?rev=1866418&view=rev


Le 01/09/2019 ? 01:11, Heather Lotz a ?crit :
Hello - Just wondering if there has been any progress made on getting <IfFile> to work for Windows.

________________________________
From: Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Sent: Saturday, August 24, 2019 11:40 AM
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>; users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>
Subject: Re: conditionally create a Virtual Host?

Seeking clarification - does this mean you were able to reproduce the issue?

________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Sent: Saturday, August 24, 2019 5:18 AM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?

Hi,

confirmed, using the binaries provided by https://www.apachelounge.com/download/

CJ

Le 23/08/2019 ? 23:53, Heather Lotz a ?crit :
Right, I have zero knowledge of C. That would be super if you would be able to replicate the issue in a Windows environment. Admittedly, I don't know what a Windows binary is.

I ran some more tests, based on your suggestion, and also found a couple of links about DOS device paths that proved to be helpful*.

Here are the results -
For each of these Apache would not start:
<IfFile "\\.\Z:">
<IfFile "\\.\Z:\">
<IfFile "\\.\Z:\files\development\ApacheSmokeSignal.txt">
<IfFile "\\.\C:">

For each of these Apache would start whether Z: was connected to the PC or not. However, the code within the <IfFile> tags never executed because localhost:8080/miscellaneous/ always returned a 404 error in the browser.
<IfFile "\\?\Z:">
<IfFile "\\?\Z:\">
<IfFile "\\?\Z:\files\development\ApacheSmokeSignal.txt">
<IfFile "\\?\C:">
<IfFile "\\?\C:\">
<IfFile "\\?\C:\Users\heather.lotz\Documents\_user_files\text.txt">

*For reference, here are links to the useful pages about DOS device paths -
https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats
https://stackoverflow.com/questions/23041983/path-prefixes-and


________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Sent: Friday, August 23, 2019 8:55 AM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?


Hi,


Ok, if you have little knowledge of C, no need to try to apply the patch.

You would need a compiler, some libraries, set-up the environment, configure, build, install...


I'll install a Windows binaries and try your configuration. Should be easy to reproduce.


The syntax you have used is correct (Z:/bla/bla/). AFAIK, the internals of httpd (the APR library to be precise) already translate the '/' (Linux style) in '\' (Windows style).


My proposal was just based on information taken from Microsoft doc (search for "When opening a volume or removable media drive (for example, a floppy disk drive or flash memory thumb drive), ..." near the end of https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew). Because, at some point, on Windows, 'CreteFileW()' is called.




Just 2 words on the patch.

When a configuration file is parsed, when a '<IfFile ...>' directive is found, all lines up to the corresponding </Iffile> are discarded.

To do that the function, we call 'apr_stat()' which gives information on a file (size, name, dates...). In the specific case, no information is requested. This is unusual. Usually we ask for size only, or "standard" information.

The patch just changes the requirement from "do not return anything" to "return size file only".

However, asking for no information *should still work*. The function should tell us that the file exists or not, without any details on the file itself, if found.

My point is that using it this way, is unusual. This could hide a corner case (read: bug in the APR underlying library)


I've had in my todo list for a long time to setup a test environment for Windows. It could be a good occasion to do it. Or you could try with the supplier of a Windows binary (Steffen from Apache lounge is following closely the project and could be of help). Reproduce the issue with their binaries and report to issue to them as well.


Finally, I put back the mailing list in copy, should anyone have an opinion on it

CJ


Le 23/08/2019 ? 14:12, Heather Lotz a ?crit :
Also, it would be helpful to know the expected syntax to use in <IfFile> once the patch is applied.

For instance, does the patch expect
<IfFile "/z/files/development/ApacheSmokeSignal.txt">
and the purpose of the patch is to execute the code within the <IfFile> tags?

Or does the patch expect
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
and the patch will allow the code within the <IfFile> tags to execute as it would on a Linux machine?

I opened the patch file in Notepad++ but don't understand the contents.

________________________________
From: Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Sent: Friday, August 23, 2019 6:44 AM
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Subject: Re: conditionally create a Virtual Host?

Hello Christophe - Thank-you for the reply. Can you please provide some instructions about how to apply the patch?
Heather

________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Sent: Friday, August 23, 2019 12:50 AM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?

Le 23/08/2019 ? 05:04, Heather Lotz a ?crit :
After some more testing, it seems that this syntax -
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
is the root cause of Apache not starting when the external storage device, mapped to Z:, is detached from the Windows 10 PC.

I tested these variants individually, which are more *nix like -
<IfFile "Z/files/development/ApacheSmokeSignal.txt">
<IfFile "/Z/files/development/ApacheSmokeSignal.txt">
<IfFile "/z/files/development/ApacheSmokeSignal.txt">
and the behavior is Apache starts whether or not Z: is attached to the PC, so that is a step in the right direction. However, the code within the <IfFile> tags never executes because when localhost:8080/miscellaneous/ is entered in a browser it always returns a 404 error.

Another test was this -
<IfFile "/c/Users/heather.lotz/Documents/_user_files/test.txt">
which points to an existing file which is not stored on Z:. The behavior here was the same as that of the 3 *nix like tests. Apache starts whether or not Z: is attached to the PC but code within the <IfFile> tags is not executed because localhost:8080/miscellaneous/ returns a 404 error.

Does this constitute a bug of <IfFile> when used on a Windows OS?

________________________________
From: Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Sent: Wednesday, August 21, 2019 9:36 PM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>
Subject: Re: [users@httpd] conditionally create a Virtual Host?

A new file was created on Z: for the sole purpose of having a designated file for Apache to seek.
The file is called Z:\files\development\ApacheSmokeSignal.txt.

Here is what httpd-vhosts.conf looks like now:
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
<VirtualHost *:8080>
DocumentRoot "Z:/files/xampp/htdocs"
<Directory "Z:/files/xampp/htdocs">
Options Indexes
Require all granted
</Directory>
</VirtualHost>
</IfFile>

With this update in place, Apache starts fine when Z: is attached to the PC. However, when Z: is not attached to the PC Apache does not start and these lines appear in the XAMPP Control Panel console:
9:30:24 PM [Apache] Attempting to start Apache app...
9:30:24 PM [Apache] Status change detected: running
9:30:26 PM [Apache] Status change detected: stopped
9:30:26 PM [Apache] Error: Apache shutdown unexpectedly.
9:30:26 PM [Apache] This may be due to a blocked port, missing dependencies,
9:30:26 PM [Apache] improper privileges, a crash, or a shutdown by another method.
9:30:26 PM [Apache] Press the Logs button to view error logs and check
9:30:26 PM [Apache] the Windows Event Viewer for more clues
9:30:26 PM [Apache] If you need more help, copy and post this
9:30:26 PM [Apache] entire log window on the forums

There are no entries in error.log with a Wed Aug 21 21:30 or later timestamp.

Is the syntax incorrect? Note that Apache is installed in this location on the PC in question: C:\xampp\apache.

________________________________
From: Eric Covener <covener@gmail.com><mailto:covener@gmail.com>
Sent: Wednesday, August 21, 2019 7:27 PM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>
Subject: Re: [users@httpd] conditionally create a Virtual Host?

On Wed, Aug 21, 2019 at 8:21 PM Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com> wrote:
>
> Greetings,
>
> In my development environment on a Windows 10 PC I have added the following to Apache's configuration files -
>
> To httpd.conf:
> Listen 8080
>
> To httpd-vhosts.conf:
> <VirtualHost *:8080>
> DocumentRoot "Z:/files/xampp/htdocs"
> <Directory "Z:/files/xampp/htdocs">
> Options Indexes
> Require all granted
> </Directory>
> </VirtualHost>
>
> Note that Z: is mapped to an external storage device.
>
> With this setup, Apache successfully accesses C: on port 80 and Z: on port 8080. However, if the external storage device is not attached to the computer, Apache will not start. Is there a way to check if Z: is present, and only create the virtual host if that device is plugged in so that Apache always starts? If so, how can this be achieved?

Try <IfFile> https://httpd.apache.org/docs/2.4/mod/core.html#iffile

--
Eric Covener
covener@gmail.com<mailto:covener@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org<mailto:users-unsubscribe@httpd.apache.org>
For additional commands, e-mail: users-help@httpd.apache.org<mailto:users-help@httpd.apache.org>


Hi,


would you have the opportunity to test the attached patch?

The 0 passed to apr_stat looks spurious to me. (but should work)



(Pure speculation)
Also, based on Microsoft doc, could you also try:

<IfFile "\\.\Z:">
...

and
<IfFile "\\.\Z:\">

...


CJ
Re: conditionally create a Virtual Host? [ In reply to ]
Hi,

we don't have a fixed schedule for release.
2.4.41 has just been released a few weeks ago.

Unless a serious regression is spotted or some security issues
discovered, you should not expect a new release before, let say, 3-4 months.
If you want to have an idea of the "release rate", have a look at [1].

CJ

[1]:
http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?revision=1866035&view=markup&sortby=date


Le 05/09/2019 ? 00:41, Heather Lotz a ?crit?:
> That is fantastic news!? Thank-you very much for figuring it out and
> fixing it.? Assuming the change gets approved, approximately when will
> the next release become available?
>
> ------------------------------------------------------------------------
> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> *Sent:* Wednesday, September 4, 2019 2:14 PM
> *To:* users@httpd.apache.org <users@httpd.apache.org>; Heather Lotz
> <knot22@hotmail.com>
> *Subject:* Re: conditionally create a Virtual Host?
> Hi,
>
> The issue has been tracked down and has been fixed on trunk in
> r1866418 [1].
>
> It will be proposed for backport and should be in next release if the
> change is approved.
>
> Best regards,
> CJ
>
> [1]: http://svn.apache.org/viewvc?rev=1866418&view=rev
> <http://svn.apache.org/viewvc?rev=1866418&view=rev>
>
>
> Le 01/09/2019 ? 01:11, Heather Lotz a ?crit?:
>> Hello - Just wondering if there has been any progress made on getting
>> <IfFile> to work for Windows.
>>
>> ------------------------------------------------------------------------
>> *From:* Heather Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>> *Sent:* Saturday, August 24, 2019 11:40 AM
>> *To:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> <mailto:christophe.jaillet@wanadoo.fr>; users@httpd.apache.org
>> <mailto:users@httpd.apache.org> <users@httpd.apache.org>
>> <mailto:users@httpd.apache.org>
>> *Subject:* Re: conditionally create a Virtual Host?
>> Seeking clarification - does this mean you were able to reproduce the
>> issue?
>>
>> ------------------------------------------------------------------------
>> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> <mailto:christophe.jaillet@wanadoo.fr>
>> *Sent:* Saturday, August 24, 2019 5:18 AM
>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>; Heather
>> Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>> *Subject:* Re: conditionally create a Virtual Host?
>> Hi,
>>
>> confirmed, using the binaries provided by
>> https://www.apachelounge.com/download/
>> <https://www.apachelounge.com/download/>
>>
>> CJ
>>
>> Le 23/08/2019 ? 23:53, Heather Lotz a ?crit?:
>>> Right, I have zero knowledge of C. That would be super if you would
>>> be able to replicate the issue in a Windows environment.?
>>> Admittedly, I don't know what a Windows binary is.
>>>
>>> I ran some more tests, based on your suggestion, and also found a
>>> couple of links about DOS device paths that proved to be helpful*.
>>>
>>> Here are the results -
>>> For each of these Apache would not start:
>>> <IfFile "\\.\Z:">
>>> <IfFile "\\.\Z:\">
>>> <IfFile "\\.\Z:\files\development\ApacheSmokeSignal.txt">
>>> <IfFile "\\.\C:">
>>>
>>> For each of these Apache would start whether Z: was connected to the
>>> PC or not.? However, the code within the <IfFile> tags never
>>> executed because localhost:8080/miscellaneous/ always returned a 404
>>> error in the browser.
>>> <IfFile "\\?\Z:">
>>> <IfFile "\\?\Z:\">
>>> <IfFile "\\?\Z:\files\development\ApacheSmokeSignal.txt">
>>> <IfFile "\\?\C:">
>>> <IfFile "\\?\C:\">
>>> <IfFile "\\?\C:\Users\heather.lotz\Documents\_user_files\text.txt">
>>>
>>> *For reference, here are links to the useful pages about DOS device
>>> paths -
>>> https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats
>>> https://stackoverflow.com/questions/23041983/path-prefixes-and
>>>
>>>
>>> ------------------------------------------------------------------------
>>> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>> <mailto:christophe.jaillet@wanadoo.fr>
>>> *Sent:* Friday, August 23, 2019 8:55 AM
>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>; Heather
>>> Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>> *Subject:* Re: conditionally create a Virtual Host?
>>>
>>> Hi,
>>>
>>>
>>> Ok, if you have little knowledge of C, no need to try to apply the
>>> patch.
>>>
>>> You would need a compiler, some libraries, set-up the environment,
>>> configure, build, install...
>>>
>>>
>>> I'll install a Windows binaries and try your configuration. Should
>>> be easy to reproduce.
>>>
>>>
>>> The syntax you have used is correct (Z:/bla/bla/). AFAIK, the
>>> internals of httpd (the APR library to be precise) already translate
>>> the '/' (Linux style) in '\' (Windows style).
>>>
>>>
>>> My proposal was just based on information taken from Microsoft doc
>>> (search for "When opening a volume or removable media drive (for
>>> example, a floppy disk drive or flash memory thumb drive), ..."?
>>> near the end of
>>> https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew).
>>> Because, at some point, on Windows, 'CreteFileW()' is called.
>>>
>>>
>>>
>>>
>>> Just 2 words on the patch.
>>>
>>> When a configuration file is parsed, when a '<IfFile ...>' directive
>>> is found, all lines up to the corresponding </Iffile> are discarded.
>>>
>>> To do that the function, we call 'apr_stat()' which gives
>>> information on a file (size, name, dates...). In the specific case,
>>> no information is requested. This is unusual. Usually we ask for
>>> size only, or "standard" information.
>>>
>>> The patch just changes the requirement from "do not return anything"
>>> to "return size file only".
>>>
>>> However, asking for no information *should still work*. The function
>>> should tell us that the file exists or not, without any details on
>>> the file itself, if found.
>>>
>>> My point is that using it this way, is unusual. This could hide a
>>> corner case (read: bug in the APR underlying library)
>>>
>>>
>>> I've had in my todo list for a long time to setup a test environment
>>> for Windows. It could be a good occasion to do it. Or you could try
>>> with the supplier of a Windows binary (Steffen from Apache lounge is
>>> following closely the project and could be of help). Reproduce the
>>> issue with their binaries and report to issue to them as well.
>>>
>>>
>>> Finally, I put back the mailing list in copy, should anyone have an
>>> opinion on it
>>>
>>> CJ
>>>
>>>
>>> Le 23/08/2019 ? 14:12, Heather Lotz a ?crit?:
>>>> Also, it would be helpful to know the expected syntax to use in
>>>> <IfFile> once the patch is applied.
>>>>
>>>> For instance, does the patch expect
>>>> <IfFile "/z/files/development/ApacheSmokeSignal.txt">
>>>> and the purpose of the patch is to execute the code within the
>>>> <IfFile> tags?
>>>>
>>>> Or does the patch expect
>>>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>>>> and the patch will allow the code within the <IfFile> tags to
>>>> execute as it would on a Linux machine?
>>>>
>>>> I opened the patch file in Notepad++ but don't understand the contents.
>>>>
>>>> ------------------------------------------------------------------------
>>>> *From:* Heather Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>>> *Sent:* Friday, August 23, 2019 6:44 AM
>>>> *To:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>>> <mailto:christophe.jaillet@wanadoo.fr>
>>>> *Subject:* Re: conditionally create a Virtual Host?
>>>> Hello Christophe - Thank-you for the reply.? Can you please provide
>>>> some instructions about how to apply the patch?
>>>> Heather
>>>>
>>>> ------------------------------------------------------------------------
>>>> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>>> <mailto:christophe.jaillet@wanadoo.fr>
>>>> *Sent:* Friday, August 23, 2019 12:50 AM
>>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>; Heather
>>>> Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>>> *Subject:* Re: conditionally create a Virtual Host?
>>>> Le 23/08/2019 ? 05:04, Heather Lotz a ?crit?:
>>>>> After some more testing, it seems that this syntax -
>>>>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>>>>> is the root cause of Apache not starting when the external storage
>>>>> device, mapped to Z:, is detached from the Windows 10 PC.
>>>>>
>>>>> I tested these variants individually, which are more *nix like -
>>>>> <IfFile "Z/files/development/ApacheSmokeSignal.txt">
>>>>> <IfFile "/Z/files/development/ApacheSmokeSignal.txt">
>>>>> <IfFile "/z/files/development/ApacheSmokeSignal.txt">
>>>>> and the behavior is Apache starts whether or not Z: is attached to
>>>>> the PC, so that is a step in the right direction. However, the
>>>>> code within the <IfFile> tags never executes because when
>>>>> localhost:8080/miscellaneous/ is entered in a browser it always
>>>>> returns a 404 error.
>>>>>
>>>>> Another test was this -
>>>>> <IfFile "/c/Users/heather.lotz/Documents/_user_files/test.txt">
>>>>> which points to an existing file which is not stored on Z:.? The
>>>>> behavior here was the same as that of the 3 *nix like tests.
>>>>> Apache starts whether or not Z: is attached to the PC but code
>>>>> within the <IfFile> tags is not executed because
>>>>> localhost:8080/miscellaneous/ returns a 404 error.
>>>>>
>>>>> Does this constitute a bug of <IfFile> when used on a Windows OS?
>>>>>
>>>>> ------------------------------------------------------------------------
>>>>> *From:* Heather Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>>>> *Sent:* Wednesday, August 21, 2019 9:36 PM
>>>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>
>>>>> *Subject:* Re: [users@httpd] conditionally create a Virtual Host?
>>>>> A new file was created on Z: for the sole purpose of having a
>>>>> designated file for Apache to seek.
>>>>> The file is? called Z:\files\development\ApacheSmokeSignal.txt.
>>>>>
>>>>> Here is what httpd-vhosts.conf looks like now:
>>>>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>>>>> <VirtualHost *:8080>
>>>>> ?DocumentRoot "Z:/files/xampp/htdocs"
>>>>> ?<Directory "Z:/files/xampp/htdocs">
>>>>> ? Options Indexes
>>>>> ? Require all granted
>>>>> ?</Directory>
>>>>> </VirtualHost>
>>>>> </IfFile>
>>>>>
>>>>> With this update in place, Apache starts fine when Z: is attached
>>>>> to the PC. However, when Z: is not attached to the PC Apache does
>>>>> not start and these lines appear in the XAMPP Control Panel console:
>>>>> 9:30:24 PM ?[Apache] ?Attempting to start Apache app...
>>>>> 9:30:24 PM ?[Apache] ?Status change detected: running
>>>>> 9:30:26 PM ?[Apache] ?Status change detected: stopped
>>>>> 9:30:26 PM ?[Apache] ?Error: Apache shutdown unexpectedly.
>>>>> 9:30:26 PM ?[Apache] ?This may be due to a blocked port, missing
>>>>> dependencies,
>>>>> 9:30:26 PM ?[Apache] ?improper privileges, a crash, or a shutdown
>>>>> by another method.
>>>>> 9:30:26 PM ?[Apache] ?Press the Logs button to view error logs and
>>>>> check
>>>>> 9:30:26 PM ?[Apache] ?the Windows Event Viewer for more clues
>>>>> 9:30:26 PM ?[Apache] ?If you need more help, copy and post this
>>>>> 9:30:26 PM ?[Apache] ?entire log window on the forums
>>>>>
>>>>> There are no entries in error.log with a Wed Aug 21 21:30 or later
>>>>> timestamp.
>>>>>
>>>>> Is the syntax incorrect? Note that Apache is installed in this
>>>>> location on the PC in question:?C:\xampp\apache.
>>>>>
>>>>> ------------------------------------------------------------------------
>>>>> *From:* Eric Covener <covener@gmail.com> <mailto:covener@gmail.com>
>>>>> *Sent:* Wednesday, August 21, 2019 7:27 PM
>>>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>
>>>>> *Subject:* Re: [users@httpd] conditionally create a Virtual Host?
>>>>> On Wed, Aug 21, 2019 at 8:21 PM Heather Lotz <knot22@hotmail.com>
>>>>> <mailto:knot22@hotmail.com> wrote:
>>>>> >
>>>>> > Greetings,
>>>>> >
>>>>> > In my development environment on a Windows 10 PC I have added
>>>>> the following to Apache's configuration files -
>>>>> >
>>>>> > To httpd.conf:
>>>>> > Listen 8080
>>>>> >
>>>>> > To httpd-vhosts.conf:
>>>>> > <VirtualHost *:8080>
>>>>> > DocumentRoot "Z:/files/xampp/htdocs"
>>>>> > <Directory "Z:/files/xampp/htdocs">
>>>>> >? Options Indexes
>>>>> >? Require all granted
>>>>> > </Directory>
>>>>> > </VirtualHost>
>>>>> >
>>>>> > Note that Z: is mapped to an external storage device.
>>>>> >
>>>>> > With this setup, Apache successfully accesses C: on port 80 and
>>>>> Z: on port 8080.? However, if the external storage device is not
>>>>> attached to the computer, Apache will not start.? Is there a way
>>>>> to check if Z: is present, and only create the virtual host if
>>>>> that device is plugged in so that Apache always starts?? If so,
>>>>> how can this be achieved?
>>>>>
>>>>> Try <IfFile> https://httpd.apache.org/docs/2.4/mod/core.html#iffile
>>>>>
>>>>> --
>>>>> Eric Covener
>>>>> covener@gmail.com <mailto:covener@gmail.com>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>>> <mailto:users-unsubscribe@httpd.apache.org>
>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>> <mailto:users-help@httpd.apache.org>
>>>>>
>>>> Hi,
>>>>
>>>>
>>>> would you have the opportunity to test the attached patch?
>>>>
>>>> The 0 passed to apr_stat looks spurious to me. (but should work)
>>>>
>>>>
>>>>
>>>> (Pure speculation)
>>>> Also, based on Microsoft doc, could you also try:
>>>>
>>>> <IfFile "\\.\Z:">
>>>> ...
>>>>
>>>> and
>>>> <IfFile "\\.\Z:\">
>>>>
>>>> ...
>>>>
>>>>
>>>> CJ
>>
>>
>
Re: conditionally create a Virtual Host? [ In reply to ]
Hi,

this has been backported to 2.4.x branch. It will be part of apache 2.4.42.
No date is foreseen at the moment. The release should happen in a couple
of months.

CJ

Le 05/09/2019 ? 21:12, Christophe JAILLET a ?crit?:
> Hi,
>
> we don't have a fixed schedule for release.
> 2.4.41 has just been released a few weeks ago.
>
> Unless a serious regression is spotted or some security issues
> discovered, you should not expect a new release before, let say, 3-4
> months.
> If you want to have an idea of the "release rate", have a look at [1].
>
> CJ
>
> [1]:
> http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?revision=1866035&view=markup&sortby=date
>
>
> Le 05/09/2019 ? 00:41, Heather Lotz a ?crit?:
>> That is fantastic news!? Thank-you very much for figuring it out and
>> fixing it. Assuming the change gets approved, approximately when will
>> the next release become available?
>>
>> ------------------------------------------------------------------------
>> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> *Sent:* Wednesday, September 4, 2019 2:14 PM
>> *To:* users@httpd.apache.org <users@httpd.apache.org>; Heather Lotz
>> <knot22@hotmail.com>
>> *Subject:* Re: conditionally create a Virtual Host?
>> Hi,
>>
>> The issue has been tracked down and has been fixed on trunk in
>> r1866418 [1].
>>
>> It will be proposed for backport and should be in next release if the
>> change is approved.
>>
>> Best regards,
>> CJ
>>
>> [1]: http://svn.apache.org/viewvc?rev=1866418&view=rev
>> <http://svn.apache.org/viewvc?rev=1866418&view=rev>
>>
>>
>> Le 01/09/2019 ? 01:11, Heather Lotz a ?crit?:
>>> Hello - Just wondering if there has been any progress made on
>>> getting <IfFile> to work for Windows.
>>>
>>> ------------------------------------------------------------------------
>>> *From:* Heather Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>> *Sent:* Saturday, August 24, 2019 11:40 AM
>>> *To:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>> <mailto:christophe.jaillet@wanadoo.fr>; users@httpd.apache.org
>>> <mailto:users@httpd.apache.org> <users@httpd.apache.org>
>>> <mailto:users@httpd.apache.org>
>>> *Subject:* Re: conditionally create a Virtual Host?
>>> Seeking clarification - does this mean you were able to reproduce
>>> the issue?
>>>
>>> ------------------------------------------------------------------------
>>> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>> <mailto:christophe.jaillet@wanadoo.fr>
>>> *Sent:* Saturday, August 24, 2019 5:18 AM
>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>; Heather
>>> Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>> *Subject:* Re: conditionally create a Virtual Host?
>>> Hi,
>>>
>>> confirmed, using the binaries provided by
>>> https://www.apachelounge.com/download/
>>> <https://www.apachelounge.com/download/>
>>>
>>> CJ
>>>
>>> Le 23/08/2019 ? 23:53, Heather Lotz a ?crit?:
>>>> Right, I have zero knowledge of C. That would be super if you would
>>>> be able to replicate the issue in a Windows environment.?
>>>> Admittedly, I don't know what a Windows binary is.
>>>>
>>>> I ran some more tests, based on your suggestion, and also found a
>>>> couple of links about DOS device paths that proved to be helpful*.
>>>>
>>>> Here are the results -
>>>> For each of these Apache would not start:
>>>> <IfFile "\\.\Z:">
>>>> <IfFile "\\.\Z:\">
>>>> <IfFile "\\.\Z:\files\development\ApacheSmokeSignal.txt">
>>>> <IfFile "\\.\C:">
>>>>
>>>> For each of these Apache would start whether Z: was connected to
>>>> the PC or not.? However, the code within the <IfFile> tags never
>>>> executed because localhost:8080/miscellaneous/ always returned a
>>>> 404 error in the browser.
>>>> <IfFile "\\?\Z:">
>>>> <IfFile "\\?\Z:\">
>>>> <IfFile "\\?\Z:\files\development\ApacheSmokeSignal.txt">
>>>> <IfFile "\\?\C:">
>>>> <IfFile "\\?\C:\">
>>>> <IfFile "\\?\C:\Users\heather.lotz\Documents\_user_files\text.txt">
>>>>
>>>> *For reference, here are links to the useful pages about DOS device
>>>> paths -
>>>> https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats
>>>> https://stackoverflow.com/questions/23041983/path-prefixes-and
>>>>
>>>>
>>>> ------------------------------------------------------------------------
>>>> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>>> <mailto:christophe.jaillet@wanadoo.fr>
>>>> *Sent:* Friday, August 23, 2019 8:55 AM
>>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>; Heather
>>>> Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>>> *Subject:* Re: conditionally create a Virtual Host?
>>>>
>>>> Hi,
>>>>
>>>>
>>>> Ok, if you have little knowledge of C, no need to try to apply the
>>>> patch.
>>>>
>>>> You would need a compiler, some libraries, set-up the environment,
>>>> configure, build, install...
>>>>
>>>>
>>>> I'll install a Windows binaries and try your configuration. Should
>>>> be easy to reproduce.
>>>>
>>>>
>>>> The syntax you have used is correct (Z:/bla/bla/). AFAIK, the
>>>> internals of httpd (the APR library to be precise) already
>>>> translate the '/' (Linux style) in '\' (Windows style).
>>>>
>>>>
>>>> My proposal was just based on information taken from Microsoft doc
>>>> (search for "When opening a volume or removable media drive (for
>>>> example, a floppy disk drive or flash memory thumb drive), ..."?
>>>> near the end of
>>>> https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew).
>>>> Because, at some point, on Windows, 'CreteFileW()' is called.
>>>>
>>>>
>>>>
>>>>
>>>> Just 2 words on the patch.
>>>>
>>>> When a configuration file is parsed, when a '<IfFile ...>'
>>>> directive is found, all lines up to the corresponding </Iffile> are
>>>> discarded.
>>>>
>>>> To do that the function, we call 'apr_stat()' which gives
>>>> information on a file (size, name, dates...). In the specific case,
>>>> no information is requested. This is unusual. Usually we ask for
>>>> size only, or "standard" information.
>>>>
>>>> The patch just changes the requirement from "do not return
>>>> anything" to "return size file only".
>>>>
>>>> However, asking for no information *should still work*. The
>>>> function should tell us that the file exists or not, without any
>>>> details on the file itself, if found.
>>>>
>>>> My point is that using it this way, is unusual. This could hide a
>>>> corner case (read: bug in the APR underlying library)
>>>>
>>>>
>>>> I've had in my todo list for a long time to setup a test
>>>> environment for Windows. It could be a good occasion to do it. Or
>>>> you could try with the supplier of a Windows binary (Steffen from
>>>> Apache lounge is following closely the project and could be of
>>>> help). Reproduce the issue with their binaries and report to issue
>>>> to them as well.
>>>>
>>>>
>>>> Finally, I put back the mailing list in copy, should anyone have an
>>>> opinion on it
>>>>
>>>> CJ
>>>>
>>>>
>>>> Le 23/08/2019 ? 14:12, Heather Lotz a ?crit?:
>>>>> Also, it would be helpful to know the expected syntax to use in
>>>>> <IfFile> once the patch is applied.
>>>>>
>>>>> For instance, does the patch expect
>>>>> <IfFile "/z/files/development/ApacheSmokeSignal.txt">
>>>>> and the purpose of the patch is to execute the code within the
>>>>> <IfFile> tags?
>>>>>
>>>>> Or does the patch expect
>>>>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>>>>> and the patch will allow the code within the <IfFile> tags to
>>>>> execute as it would on a Linux machine?
>>>>>
>>>>> I opened the patch file in Notepad++ but don't understand the
>>>>> contents.
>>>>>
>>>>> ------------------------------------------------------------------------
>>>>> *From:* Heather Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>>>> *Sent:* Friday, August 23, 2019 6:44 AM
>>>>> *To:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>>>> <mailto:christophe.jaillet@wanadoo.fr>
>>>>> *Subject:* Re: conditionally create a Virtual Host?
>>>>> Hello Christophe - Thank-you for the reply.? Can you please
>>>>> provide some instructions about how to apply the patch?
>>>>> Heather
>>>>>
>>>>> ------------------------------------------------------------------------
>>>>> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>>>> <mailto:christophe.jaillet@wanadoo.fr>
>>>>> *Sent:* Friday, August 23, 2019 12:50 AM
>>>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>; Heather
>>>>> Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>>>> *Subject:* Re: conditionally create a Virtual Host?
>>>>> Le 23/08/2019 ? 05:04, Heather Lotz a ?crit?:
>>>>>> After some more testing, it seems that this syntax -
>>>>>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>>>>>> is the root cause of Apache not starting when the external
>>>>>> storage device, mapped to Z:, is detached from the Windows 10 PC.
>>>>>>
>>>>>> I tested these variants individually, which are more *nix like -
>>>>>> <IfFile "Z/files/development/ApacheSmokeSignal.txt">
>>>>>> <IfFile "/Z/files/development/ApacheSmokeSignal.txt">
>>>>>> <IfFile "/z/files/development/ApacheSmokeSignal.txt">
>>>>>> and the behavior is Apache starts whether or not Z: is attached
>>>>>> to the PC, so that is a step in the right direction. However, the
>>>>>> code within the <IfFile> tags never executes because when
>>>>>> localhost:8080/miscellaneous/ is entered in a browser it always
>>>>>> returns a 404 error.
>>>>>>
>>>>>> Another test was this -
>>>>>> <IfFile "/c/Users/heather.lotz/Documents/_user_files/test.txt">
>>>>>> which points to an existing file which is not stored on Z:. The
>>>>>> behavior here was the same as that of the 3 *nix like tests.?
>>>>>> Apache starts whether or not Z: is attached to the PC but code
>>>>>> within the <IfFile> tags is not executed because
>>>>>> localhost:8080/miscellaneous/ returns a 404 error.
>>>>>>
>>>>>> Does this constitute a bug of <IfFile> when used on a Windows OS?
>>>>>>
>>>>>> ------------------------------------------------------------------------
>>>>>> *From:* Heather Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>>>>> *Sent:* Wednesday, August 21, 2019 9:36 PM
>>>>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>>>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>
>>>>>> *Subject:* Re: [users@httpd] conditionally create a Virtual Host?
>>>>>> A new file was created on Z: for the sole purpose of having a
>>>>>> designated file for Apache to seek.
>>>>>> The file is? called Z:\files\development\ApacheSmokeSignal.txt.
>>>>>>
>>>>>> Here is what httpd-vhosts.conf looks like now:
>>>>>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>>>>>> <VirtualHost *:8080>
>>>>>> ?DocumentRoot "Z:/files/xampp/htdocs"
>>>>>> ?<Directory "Z:/files/xampp/htdocs">
>>>>>> ? Options Indexes
>>>>>> ? Require all granted
>>>>>> ?</Directory>
>>>>>> </VirtualHost>
>>>>>> </IfFile>
>>>>>>
>>>>>> With this update in place, Apache starts fine when Z: is attached
>>>>>> to the PC. However, when Z: is not attached to the PC Apache does
>>>>>> not start and these lines appear in the XAMPP Control Panel console:
>>>>>> 9:30:24 PM ?[Apache] ?Attempting to start Apache app...
>>>>>> 9:30:24 PM ?[Apache] ?Status change detected: running
>>>>>> 9:30:26 PM ?[Apache] ?Status change detected: stopped
>>>>>> 9:30:26 PM ?[Apache] ?Error: Apache shutdown unexpectedly.
>>>>>> 9:30:26 PM ?[Apache] ?This may be due to a blocked port, missing
>>>>>> dependencies,
>>>>>> 9:30:26 PM ?[Apache] ?improper privileges, a crash, or a shutdown
>>>>>> by another method.
>>>>>> 9:30:26 PM ?[Apache] ?Press the Logs button to view error logs
>>>>>> and check
>>>>>> 9:30:26 PM ?[Apache] ?the Windows Event Viewer for more clues
>>>>>> 9:30:26 PM ?[Apache] ?If you need more help, copy and post this
>>>>>> 9:30:26 PM ?[Apache] ?entire log window on the forums
>>>>>>
>>>>>> There are no entries in error.log with a Wed Aug 21 21:30 or
>>>>>> later timestamp.
>>>>>>
>>>>>> Is the syntax incorrect? Note that Apache is installed in this
>>>>>> location on the PC in question:?C:\xampp\apache.
>>>>>>
>>>>>> ------------------------------------------------------------------------
>>>>>> *From:* Eric Covener <covener@gmail.com> <mailto:covener@gmail.com>
>>>>>> *Sent:* Wednesday, August 21, 2019 7:27 PM
>>>>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>>>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>
>>>>>> *Subject:* Re: [users@httpd] conditionally create a Virtual Host?
>>>>>> On Wed, Aug 21, 2019 at 8:21 PM Heather Lotz <knot22@hotmail.com>
>>>>>> <mailto:knot22@hotmail.com> wrote:
>>>>>> >
>>>>>> > Greetings,
>>>>>> >
>>>>>> > In my development environment on a Windows 10 PC I have added
>>>>>> the following to Apache's configuration files -
>>>>>> >
>>>>>> > To httpd.conf:
>>>>>> > Listen 8080
>>>>>> >
>>>>>> > To httpd-vhosts.conf:
>>>>>> > <VirtualHost *:8080>
>>>>>> > DocumentRoot "Z:/files/xampp/htdocs"
>>>>>> > <Directory "Z:/files/xampp/htdocs">
>>>>>> >? Options Indexes
>>>>>> >? Require all granted
>>>>>> > </Directory>
>>>>>> > </VirtualHost>
>>>>>> >
>>>>>> > Note that Z: is mapped to an external storage device.
>>>>>> >
>>>>>> > With this setup, Apache successfully accesses C: on port 80 and
>>>>>> Z: on port 8080. However, if the external storage device is not
>>>>>> attached to the computer, Apache will not start. Is there a way
>>>>>> to check if Z: is present, and only create the virtual host if
>>>>>> that device is plugged in so that Apache always starts?? If so,
>>>>>> how can this be achieved?
>>>>>>
>>>>>> Try <IfFile> https://httpd.apache.org/docs/2.4/mod/core.html#iffile
>>>>>>
>>>>>> --
>>>>>> Eric Covener
>>>>>> covener@gmail.com <mailto:covener@gmail.com>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>>>> <mailto:users-unsubscribe@httpd.apache.org>
>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>>> <mailto:users-help@httpd.apache.org>
>>>>>>
>>>>> Hi,
>>>>>
>>>>>
>>>>> would you have the opportunity to test the attached patch?
>>>>>
>>>>> The 0 passed to apr_stat looks spurious to me. (but should work)
>>>>>
>>>>>
>>>>>
>>>>> (Pure speculation)
>>>>> Also, based on Microsoft doc, could you also try:
>>>>>
>>>>> <IfFile "\\.\Z:">
>>>>> ...
>>>>>
>>>>> and
>>>>> <IfFile "\\.\Z:\">
>>>>>
>>>>> ...
>>>>>
>>>>>
>>>>> CJ
>>>
>>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: conditionally create a Virtual Host? [ In reply to ]
Excellent! Thank-you for the update.

________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Sent: Saturday, November 9, 2019 3:32 PM
To: users@httpd.apache.org <users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?

Hi,

this has been backported to 2.4.x branch. It will be part of apache 2.4.42.
No date is foreseen at the moment. The release should happen in a couple
of months.

CJ

Le 05/09/2019 ? 21:12, Christophe JAILLET a ?crit :
> Hi,
>
> we don't have a fixed schedule for release.
> 2.4.41 has just been released a few weeks ago.
>
> Unless a serious regression is spotted or some security issues
> discovered, you should not expect a new release before, let say, 3-4
> months.
> If you want to have an idea of the "release rate", have a look at [1].
>
> CJ
>
> [1]:
> http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?revision=1866035&view=markup&sortby=date
>
>
> Le 05/09/2019 ? 00:41, Heather Lotz a ?crit :
>> That is fantastic news! Thank-you very much for figuring it out and
>> fixing it. Assuming the change gets approved, approximately when will
>> the next release become available?
>>
>> ------------------------------------------------------------------------
>> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> *Sent:* Wednesday, September 4, 2019 2:14 PM
>> *To:* users@httpd.apache.org <users@httpd.apache.org>; Heather Lotz
>> <knot22@hotmail.com>
>> *Subject:* Re: conditionally create a Virtual Host?
>> Hi,
>>
>> The issue has been tracked down and has been fixed on trunk in
>> r1866418 [1].
>>
>> It will be proposed for backport and should be in next release if the
>> change is approved.
>>
>> Best regards,
>> CJ
>>
>> [1]: http://svn.apache.org/viewvc?rev=1866418&view=rev
>> <http://svn.apache.org/viewvc?rev=1866418&view=rev>
>>
>>
>> Le 01/09/2019 ? 01:11, Heather Lotz a ?crit :
>>> Hello - Just wondering if there has been any progress made on
>>> getting <IfFile> to work for Windows.
>>>
>>> ------------------------------------------------------------------------
>>> *From:* Heather Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>> *Sent:* Saturday, August 24, 2019 11:40 AM
>>> *To:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>> <mailto:christophe.jaillet@wanadoo.fr>; users@httpd.apache.org
>>> <mailto:users@httpd.apache.org> <users@httpd.apache.org>
>>> <mailto:users@httpd.apache.org>
>>> *Subject:* Re: conditionally create a Virtual Host?
>>> Seeking clarification - does this mean you were able to reproduce
>>> the issue?
>>>
>>> ------------------------------------------------------------------------
>>> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>> <mailto:christophe.jaillet@wanadoo.fr>
>>> *Sent:* Saturday, August 24, 2019 5:18 AM
>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>; Heather
>>> Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>> *Subject:* Re: conditionally create a Virtual Host?
>>> Hi,
>>>
>>> confirmed, using the binaries provided by
>>> https://www.apachelounge.com/download/
>>> <https://www.apachelounge.com/download/>
>>>
>>> CJ
>>>
>>> Le 23/08/2019 ? 23:53, Heather Lotz a ?crit :
>>>> Right, I have zero knowledge of C. That would be super if you would
>>>> be able to replicate the issue in a Windows environment.
>>>> Admittedly, I don't know what a Windows binary is.
>>>>
>>>> I ran some more tests, based on your suggestion, and also found a
>>>> couple of links about DOS device paths that proved to be helpful*.
>>>>
>>>> Here are the results -
>>>> For each of these Apache would not start:
>>>> <IfFile "\\.\Z:">
>>>> <IfFile "\\.\Z:\">
>>>> <IfFile "\\.\Z:\files\development\ApacheSmokeSignal.txt">
>>>> <IfFile "\\.\C:">
>>>>
>>>> For each of these Apache would start whether Z: was connected to
>>>> the PC or not. However, the code within the <IfFile> tags never
>>>> executed because localhost:8080/miscellaneous/ always returned a
>>>> 404 error in the browser.
>>>> <IfFile "\\?\Z:">
>>>> <IfFile "\\?\Z:\">
>>>> <IfFile "\\?\Z:\files\development\ApacheSmokeSignal.txt">
>>>> <IfFile "\\?\C:">
>>>> <IfFile "\\?\C:\">
>>>> <IfFile "\\?\C:\Users\heather.lotz\Documents\_user_files\text.txt">
>>>>
>>>> *For reference, here are links to the useful pages about DOS device
>>>> paths -
>>>> https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats
>>>> https://stackoverflow.com/questions/23041983/path-prefixes-and
>>>>
>>>>
>>>> ------------------------------------------------------------------------
>>>> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>>> <mailto:christophe.jaillet@wanadoo.fr>
>>>> *Sent:* Friday, August 23, 2019 8:55 AM
>>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>; Heather
>>>> Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>>> *Subject:* Re: conditionally create a Virtual Host?
>>>>
>>>> Hi,
>>>>
>>>>
>>>> Ok, if you have little knowledge of C, no need to try to apply the
>>>> patch.
>>>>
>>>> You would need a compiler, some libraries, set-up the environment,
>>>> configure, build, install...
>>>>
>>>>
>>>> I'll install a Windows binaries and try your configuration. Should
>>>> be easy to reproduce.
>>>>
>>>>
>>>> The syntax you have used is correct (Z:/bla/bla/). AFAIK, the
>>>> internals of httpd (the APR library to be precise) already
>>>> translate the '/' (Linux style) in '\' (Windows style).
>>>>
>>>>
>>>> My proposal was just based on information taken from Microsoft doc
>>>> (search for "When opening a volume or removable media drive (for
>>>> example, a floppy disk drive or flash memory thumb drive), ..."
>>>> near the end of
>>>> https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew).
>>>> Because, at some point, on Windows, 'CreteFileW()' is called.
>>>>
>>>>
>>>>
>>>>
>>>> Just 2 words on the patch.
>>>>
>>>> When a configuration file is parsed, when a '<IfFile ...>'
>>>> directive is found, all lines up to the corresponding </Iffile> are
>>>> discarded.
>>>>
>>>> To do that the function, we call 'apr_stat()' which gives
>>>> information on a file (size, name, dates...). In the specific case,
>>>> no information is requested. This is unusual. Usually we ask for
>>>> size only, or "standard" information.
>>>>
>>>> The patch just changes the requirement from "do not return
>>>> anything" to "return size file only".
>>>>
>>>> However, asking for no information *should still work*. The
>>>> function should tell us that the file exists or not, without any
>>>> details on the file itself, if found.
>>>>
>>>> My point is that using it this way, is unusual. This could hide a
>>>> corner case (read: bug in the APR underlying library)
>>>>
>>>>
>>>> I've had in my todo list for a long time to setup a test
>>>> environment for Windows. It could be a good occasion to do it. Or
>>>> you could try with the supplier of a Windows binary (Steffen from
>>>> Apache lounge is following closely the project and could be of
>>>> help). Reproduce the issue with their binaries and report to issue
>>>> to them as well.
>>>>
>>>>
>>>> Finally, I put back the mailing list in copy, should anyone have an
>>>> opinion on it
>>>>
>>>> CJ
>>>>
>>>>
>>>> Le 23/08/2019 ? 14:12, Heather Lotz a ?crit :
>>>>> Also, it would be helpful to know the expected syntax to use in
>>>>> <IfFile> once the patch is applied.
>>>>>
>>>>> For instance, does the patch expect
>>>>> <IfFile "/z/files/development/ApacheSmokeSignal.txt">
>>>>> and the purpose of the patch is to execute the code within the
>>>>> <IfFile> tags?
>>>>>
>>>>> Or does the patch expect
>>>>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>>>>> and the patch will allow the code within the <IfFile> tags to
>>>>> execute as it would on a Linux machine?
>>>>>
>>>>> I opened the patch file in Notepad++ but don't understand the
>>>>> contents.
>>>>>
>>>>> ------------------------------------------------------------------------
>>>>> *From:* Heather Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>>>> *Sent:* Friday, August 23, 2019 6:44 AM
>>>>> *To:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>>>> <mailto:christophe.jaillet@wanadoo.fr>
>>>>> *Subject:* Re: conditionally create a Virtual Host?
>>>>> Hello Christophe - Thank-you for the reply. Can you please
>>>>> provide some instructions about how to apply the patch?
>>>>> Heather
>>>>>
>>>>> ------------------------------------------------------------------------
>>>>> *From:* Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>>>> <mailto:christophe.jaillet@wanadoo.fr>
>>>>> *Sent:* Friday, August 23, 2019 12:50 AM
>>>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>; Heather
>>>>> Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>>>> *Subject:* Re: conditionally create a Virtual Host?
>>>>> Le 23/08/2019 ? 05:04, Heather Lotz a ?crit :
>>>>>> After some more testing, it seems that this syntax -
>>>>>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>>>>>> is the root cause of Apache not starting when the external
>>>>>> storage device, mapped to Z:, is detached from the Windows 10 PC.
>>>>>>
>>>>>> I tested these variants individually, which are more *nix like -
>>>>>> <IfFile "Z/files/development/ApacheSmokeSignal.txt">
>>>>>> <IfFile "/Z/files/development/ApacheSmokeSignal.txt">
>>>>>> <IfFile "/z/files/development/ApacheSmokeSignal.txt">
>>>>>> and the behavior is Apache starts whether or not Z: is attached
>>>>>> to the PC, so that is a step in the right direction. However, the
>>>>>> code within the <IfFile> tags never executes because when
>>>>>> localhost:8080/miscellaneous/ is entered in a browser it always
>>>>>> returns a 404 error.
>>>>>>
>>>>>> Another test was this -
>>>>>> <IfFile "/c/Users/heather.lotz/Documents/_user_files/test.txt">
>>>>>> which points to an existing file which is not stored on Z:. The
>>>>>> behavior here was the same as that of the 3 *nix like tests.
>>>>>> Apache starts whether or not Z: is attached to the PC but code
>>>>>> within the <IfFile> tags is not executed because
>>>>>> localhost:8080/miscellaneous/ returns a 404 error.
>>>>>>
>>>>>> Does this constitute a bug of <IfFile> when used on a Windows OS?
>>>>>>
>>>>>> ------------------------------------------------------------------------
>>>>>> *From:* Heather Lotz <knot22@hotmail.com> <mailto:knot22@hotmail.com>
>>>>>> *Sent:* Wednesday, August 21, 2019 9:36 PM
>>>>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>>>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>
>>>>>> *Subject:* Re: [users@httpd] conditionally create a Virtual Host?
>>>>>> A new file was created on Z: for the sole purpose of having a
>>>>>> designated file for Apache to seek.
>>>>>> The file is called Z:\files\development\ApacheSmokeSignal.txt.
>>>>>>
>>>>>> Here is what httpd-vhosts.conf looks like now:
>>>>>> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
>>>>>> <VirtualHost *:8080>
>>>>>> DocumentRoot "Z:/files/xampp/htdocs"
>>>>>> <Directory "Z:/files/xampp/htdocs">
>>>>>> Options Indexes
>>>>>> Require all granted
>>>>>> </Directory>
>>>>>> </VirtualHost>
>>>>>> </IfFile>
>>>>>>
>>>>>> With this update in place, Apache starts fine when Z: is attached
>>>>>> to the PC. However, when Z: is not attached to the PC Apache does
>>>>>> not start and these lines appear in the XAMPP Control Panel console:
>>>>>> 9:30:24 PM [Apache] Attempting to start Apache app...
>>>>>> 9:30:24 PM [Apache] Status change detected: running
>>>>>> 9:30:26 PM [Apache] Status change detected: stopped
>>>>>> 9:30:26 PM [Apache] Error: Apache shutdown unexpectedly.
>>>>>> 9:30:26 PM [Apache] This may be due to a blocked port, missing
>>>>>> dependencies,
>>>>>> 9:30:26 PM [Apache] improper privileges, a crash, or a shutdown
>>>>>> by another method.
>>>>>> 9:30:26 PM [Apache] Press the Logs button to view error logs
>>>>>> and check
>>>>>> 9:30:26 PM [Apache] the Windows Event Viewer for more clues
>>>>>> 9:30:26 PM [Apache] If you need more help, copy and post this
>>>>>> 9:30:26 PM [Apache] entire log window on the forums
>>>>>>
>>>>>> There are no entries in error.log with a Wed Aug 21 21:30 or
>>>>>> later timestamp.
>>>>>>
>>>>>> Is the syntax incorrect? Note that Apache is installed in this
>>>>>> location on the PC in question: C:\xampp\apache.
>>>>>>
>>>>>> ------------------------------------------------------------------------
>>>>>> *From:* Eric Covener <covener@gmail.com> <mailto:covener@gmail.com>
>>>>>> *Sent:* Wednesday, August 21, 2019 7:27 PM
>>>>>> *To:* users@httpd.apache.org <mailto:users@httpd.apache.org>
>>>>>> <users@httpd.apache.org> <mailto:users@httpd.apache.org>
>>>>>> *Subject:* Re: [users@httpd] conditionally create a Virtual Host?
>>>>>> On Wed, Aug 21, 2019 at 8:21 PM Heather Lotz <knot22@hotmail.com>
>>>>>> <mailto:knot22@hotmail.com> wrote:
>>>>>> >
>>>>>> > Greetings,
>>>>>> >
>>>>>> > In my development environment on a Windows 10 PC I have added
>>>>>> the following to Apache's configuration files -
>>>>>> >
>>>>>> > To httpd.conf:
>>>>>> > Listen 8080
>>>>>> >
>>>>>> > To httpd-vhosts.conf:
>>>>>> > <VirtualHost *:8080>
>>>>>> > DocumentRoot "Z:/files/xampp/htdocs"
>>>>>> > <Directory "Z:/files/xampp/htdocs">
>>>>>> > Options Indexes
>>>>>> > Require all granted
>>>>>> > </Directory>
>>>>>> > </VirtualHost>
>>>>>> >
>>>>>> > Note that Z: is mapped to an external storage device.
>>>>>> >
>>>>>> > With this setup, Apache successfully accesses C: on port 80 and
>>>>>> Z: on port 8080. However, if the external storage device is not
>>>>>> attached to the computer, Apache will not start. Is there a way
>>>>>> to check if Z: is present, and only create the virtual host if
>>>>>> that device is plugged in so that Apache always starts? If so,
>>>>>> how can this be achieved?
>>>>>>
>>>>>> Try <IfFile> https://httpd.apache.org/docs/2.4/mod/core.html#iffile
>>>>>>
>>>>>> --
>>>>>> Eric Covener
>>>>>> covener@gmail.com <mailto:covener@gmail.com>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>>>> <mailto:users-unsubscribe@httpd.apache.org>
>>>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>>> <mailto:users-help@httpd.apache.org>
>>>>>>
>>>>> Hi,
>>>>>
>>>>>
>>>>> would you have the opportunity to test the attached patch?
>>>>>
>>>>> The 0 passed to apr_stat looks spurious to me. (but should work)
>>>>>
>>>>>
>>>>>
>>>>> (Pure speculation)
>>>>> Also, based on Microsoft doc, could you also try:
>>>>>
>>>>> <IfFile "\\.\Z:">
>>>>> ...
>>>>>
>>>>> and
>>>>> <IfFile "\\.\Z:\">
>>>>>
>>>>> ...
>>>>>
>>>>>
>>>>> CJ
>>>
>>>
>>
>
Re: conditionally create a Virtual Host? [ In reply to ]
Was this change released in a patch or will it be released in the next minor version?

________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Sent: Thursday, September 5, 2019 2:12 PM
To: users@httpd.apache.org <users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?

Hi,

we don't have a fixed schedule for release.
2.4.41 has just been released a few weeks ago.

Unless a serious regression is spotted or some security issues discovered, you should not expect a new release before, let say, 3-4 months.
If you want to have an idea of the "release rate", have a look at [1].

CJ

[1]: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?revision=1866035&view=markup&sortby=date


Le 05/09/2019 ? 00:41, Heather Lotz a ?crit :
That is fantastic news! Thank-you very much for figuring it out and fixing it. Assuming the change gets approved, approximately when will the next release become available?

________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Sent: Wednesday, September 4, 2019 2:14 PM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?

Hi,

The issue has been tracked down and has been fixed on trunk in r1866418 [1].

It will be proposed for backport and should be in next release if the change is approved.

Best regards,
CJ

[1]: http://svn.apache.org/viewvc?rev=1866418&view=rev


Le 01/09/2019 ? 01:11, Heather Lotz a ?crit :
Hello - Just wondering if there has been any progress made on getting <IfFile> to work for Windows.

________________________________
From: Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Sent: Saturday, August 24, 2019 11:40 AM
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>; users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>
Subject: Re: conditionally create a Virtual Host?

Seeking clarification - does this mean you were able to reproduce the issue?

________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Sent: Saturday, August 24, 2019 5:18 AM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?

Hi,

confirmed, using the binaries provided by https://www.apachelounge.com/download/

CJ

Le 23/08/2019 ? 23:53, Heather Lotz a ?crit :
Right, I have zero knowledge of C. That would be super if you would be able to replicate the issue in a Windows environment. Admittedly, I don't know what a Windows binary is.

I ran some more tests, based on your suggestion, and also found a couple of links about DOS device paths that proved to be helpful*.

Here are the results -
For each of these Apache would not start:
<IfFile "\\.\Z:">
<IfFile "\\.\Z:\">
<IfFile "\\.\Z:\files\development\ApacheSmokeSignal.txt">
<IfFile "\\.\C:">

For each of these Apache would start whether Z: was connected to the PC or not. However, the code within the <IfFile> tags never executed because localhost:8080/miscellaneous/ always returned a 404 error in the browser.
<IfFile "\\?\Z:">
<IfFile "\\?\Z:\">
<IfFile "\\?\Z:\files\development\ApacheSmokeSignal.txt">
<IfFile "\\?\C:">
<IfFile "\\?\C:\">
<IfFile "\\?\C:\Users\heather.lotz\Documents\_user_files\text.txt">

*For reference, here are links to the useful pages about DOS device paths -
https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats
https://stackoverflow.com/questions/23041983/path-prefixes-and


________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Sent: Friday, August 23, 2019 8:55 AM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?


Hi,


Ok, if you have little knowledge of C, no need to try to apply the patch.

You would need a compiler, some libraries, set-up the environment, configure, build, install...


I'll install a Windows binaries and try your configuration. Should be easy to reproduce.


The syntax you have used is correct (Z:/bla/bla/). AFAIK, the internals of httpd (the APR library to be precise) already translate the '/' (Linux style) in '\' (Windows style).


My proposal was just based on information taken from Microsoft doc (search for "When opening a volume or removable media drive (for example, a floppy disk drive or flash memory thumb drive), ..." near the end of https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew). Because, at some point, on Windows, 'CreteFileW()' is called.




Just 2 words on the patch.

When a configuration file is parsed, when a '<IfFile ...>' directive is found, all lines up to the corresponding </Iffile> are discarded.

To do that the function, we call 'apr_stat()' which gives information on a file (size, name, dates...). In the specific case, no information is requested. This is unusual. Usually we ask for size only, or "standard" information.

The patch just changes the requirement from "do not return anything" to "return size file only".

However, asking for no information *should still work*. The function should tell us that the file exists or not, without any details on the file itself, if found.

My point is that using it this way, is unusual. This could hide a corner case (read: bug in the APR underlying library)


I've had in my todo list for a long time to setup a test environment for Windows. It could be a good occasion to do it. Or you could try with the supplier of a Windows binary (Steffen from Apache lounge is following closely the project and could be of help). Reproduce the issue with their binaries and report to issue to them as well.


Finally, I put back the mailing list in copy, should anyone have an opinion on it

CJ


Le 23/08/2019 ? 14:12, Heather Lotz a ?crit :
Also, it would be helpful to know the expected syntax to use in <IfFile> once the patch is applied.

For instance, does the patch expect
<IfFile "/z/files/development/ApacheSmokeSignal.txt">
and the purpose of the patch is to execute the code within the <IfFile> tags?

Or does the patch expect
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
and the patch will allow the code within the <IfFile> tags to execute as it would on a Linux machine?

I opened the patch file in Notepad++ but don't understand the contents.

________________________________
From: Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Sent: Friday, August 23, 2019 6:44 AM
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Subject: Re: conditionally create a Virtual Host?

Hello Christophe - Thank-you for the reply. Can you please provide some instructions about how to apply the patch?
Heather

________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Sent: Friday, August 23, 2019 12:50 AM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?

Le 23/08/2019 ? 05:04, Heather Lotz a ?crit :
After some more testing, it seems that this syntax -
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
is the root cause of Apache not starting when the external storage device, mapped to Z:, is detached from the Windows 10 PC.

I tested these variants individually, which are more *nix like -
<IfFile "Z/files/development/ApacheSmokeSignal.txt">
<IfFile "/Z/files/development/ApacheSmokeSignal.txt">
<IfFile "/z/files/development/ApacheSmokeSignal.txt">
and the behavior is Apache starts whether or not Z: is attached to the PC, so that is a step in the right direction. However, the code within the <IfFile> tags never executes because when localhost:8080/miscellaneous/ is entered in a browser it always returns a 404 error.

Another test was this -
<IfFile "/c/Users/heather.lotz/Documents/_user_files/test.txt">
which points to an existing file which is not stored on Z:. The behavior here was the same as that of the 3 *nix like tests. Apache starts whether or not Z: is attached to the PC but code within the <IfFile> tags is not executed because localhost:8080/miscellaneous/ returns a 404 error.

Does this constitute a bug of <IfFile> when used on a Windows OS?

________________________________
From: Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Sent: Wednesday, August 21, 2019 9:36 PM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>
Subject: Re: [users@httpd] conditionally create a Virtual Host?

A new file was created on Z: for the sole purpose of having a designated file for Apache to seek.
The file is called Z:\files\development\ApacheSmokeSignal.txt.

Here is what httpd-vhosts.conf looks like now:
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
<VirtualHost *:8080>
DocumentRoot "Z:/files/xampp/htdocs"
<Directory "Z:/files/xampp/htdocs">
Options Indexes
Require all granted
</Directory>
</VirtualHost>
</IfFile>

With this update in place, Apache starts fine when Z: is attached to the PC. However, when Z: is not attached to the PC Apache does not start and these lines appear in the XAMPP Control Panel console:
9:30:24 PM [Apache] Attempting to start Apache app...
9:30:24 PM [Apache] Status change detected: running
9:30:26 PM [Apache] Status change detected: stopped
9:30:26 PM [Apache] Error: Apache shutdown unexpectedly.
9:30:26 PM [Apache] This may be due to a blocked port, missing dependencies,
9:30:26 PM [Apache] improper privileges, a crash, or a shutdown by another method.
9:30:26 PM [Apache] Press the Logs button to view error logs and check
9:30:26 PM [Apache] the Windows Event Viewer for more clues
9:30:26 PM [Apache] If you need more help, copy and post this
9:30:26 PM [Apache] entire log window on the forums

There are no entries in error.log with a Wed Aug 21 21:30 or later timestamp.

Is the syntax incorrect? Note that Apache is installed in this location on the PC in question: C:\xampp\apache.

________________________________
From: Eric Covener <covener@gmail.com><mailto:covener@gmail.com>
Sent: Wednesday, August 21, 2019 7:27 PM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>
Subject: Re: [users@httpd] conditionally create a Virtual Host?

On Wed, Aug 21, 2019 at 8:21 PM Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com> wrote:
>
> Greetings,
>
> In my development environment on a Windows 10 PC I have added the following to Apache's configuration files -
>
> To httpd.conf:
> Listen 8080
>
> To httpd-vhosts.conf:
> <VirtualHost *:8080>
> DocumentRoot "Z:/files/xampp/htdocs"
> <Directory "Z:/files/xampp/htdocs">
> Options Indexes
> Require all granted
> </Directory>
> </VirtualHost>
>
> Note that Z: is mapped to an external storage device.
>
> With this setup, Apache successfully accesses C: on port 80 and Z: on port 8080. However, if the external storage device is not attached to the computer, Apache will not start. Is there a way to check if Z: is present, and only create the virtual host if that device is plugged in so that Apache always starts? If so, how can this be achieved?

Try <IfFile> https://httpd.apache.org/docs/2.4/mod/core.html#iffile

--
Eric Covener
covener@gmail.com<mailto:covener@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org<mailto:users-unsubscribe@httpd.apache.org>
For additional commands, e-mail: users-help@httpd.apache.org<mailto:users-help@httpd.apache.org>


Hi,


would you have the opportunity to test the attached patch?

The 0 passed to apr_stat looks spurious to me. (but should work)



(Pure speculation)
Also, based on Microsoft doc, could you also try:

<IfFile "\\.\Z:">
...

and
<IfFile "\\.\Z:\">

...


CJ
Re: Re: conditionally create a Virtual Host? [ In reply to ]
On Tue, Oct 13, 2020 at 8:11 AM Heather Lotz <knot22@hotmail.com> wrote:
>
> Was this change released in a patch or will it be released in the next minor version?

The change is part of 2.4.43 (and later)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: conditionally create a Virtual Host? [ In reply to ]
Recently, I upgraded to Apache 2.4.46 on my Windows 10 laptop and tried modifying httpd-vhosts.conf to conditionally create the Virtual Host as follows:

<IfFile "Z/files/development/ApacheSmokeSignal.txt">
<VirtualHost *:8080>
DocumentRoot "Z:/files/development/xampp/code/htdocs"
<Directory "Z:/files/development/xampp/code/htdocs">
Options Indexes
Require all granted
</Directory>
</VirtualHost>
</IfFile>

Unfortunately, it is exhibiting the exact same behavior as documented earlier -
Apache starts whether or not the external drive that's mapped to Z: is attached to the PC. However, code within the <IfFile> tags is not executed because localhost:8080/miscellaneous/ returns a 404 error, even though that is a valid address. When the <IfFile> tags are commented out then localhost:8080/miscellaneous/ resolves correctly (Z: has to be attached when the <IfFile> tags are disabled so Apache will start).

I have also tried
<IfFile "\\?\Z:">
# same VirtualHost code as above
</IfFile>
but get the exact same result as described above.

Since a fix was created, tested, then deployed in Apache 2.4.43 for this specific issue I'm wondering why it's still behaving as it was prior to version 2.4.43 on my laptop. Thoughts?

-----------------------------------------------------------------------------------------------------------------------------------------------------

From:Eric Covener <covener@gmail.com>
Sent:Tuesday, October 13, 2020 7:28 AM
To:users@httpd.apache.org <users@httpd.apache.org>
Cc:Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Subject:Re: [users@httpd] Re: conditionally create a Virtual Host?

On Tue, Oct 13, 2020 at 8:11 AM Heather Lotz <knot22@hotmail.com> wrote:
>
> Was this change released in a patch or will it be released in the next minor version?

The change is part of 2.4.43 (and later)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


________________________________
From: Heather Lotz <knot22@hotmail.com>
Sent: Tuesday, October 13, 2020 7:11 AM
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>; users@httpd.apache.org <users@httpd.apache.org>
Subject: [users@httpd] Re: conditionally create a Virtual Host?

Was this change released in a patch or will it be released in the next minor version?

________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Sent: Thursday, September 5, 2019 2:12 PM
To: users@httpd.apache.org <users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?

Hi,

we don't have a fixed schedule for release.
2.4.41 has just been released a few weeks ago.

Unless a serious regression is spotted or some security issues discovered, you should not expect a new release before, let say, 3-4 months.
If you want to have an idea of the "release rate", have a look at [1].

CJ

[1]: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?revision=1866035&view=markup&sortby=date


Le 05/09/2019 ? 00:41, Heather Lotz a ?crit :
That is fantastic news! Thank-you very much for figuring it out and fixing it. Assuming the change gets approved, approximately when will the next release become available?

________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Sent: Wednesday, September 4, 2019 2:14 PM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?

Hi,

The issue has been tracked down and has been fixed on trunk in r1866418 [1].

It will be proposed for backport and should be in next release if the change is approved.

Best regards,
CJ

[1]: http://svn.apache.org/viewvc?rev=1866418&view=rev


Le 01/09/2019 ? 01:11, Heather Lotz a ?crit :
Hello - Just wondering if there has been any progress made on getting <IfFile> to work for Windows.

________________________________
From: Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Sent: Saturday, August 24, 2019 11:40 AM
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>; users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>
Subject: Re: conditionally create a Virtual Host?

Seeking clarification - does this mean you were able to reproduce the issue?

________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Sent: Saturday, August 24, 2019 5:18 AM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?

Hi,

confirmed, using the binaries provided by https://www.apachelounge.com/download/

CJ

Le 23/08/2019 ? 23:53, Heather Lotz a ?crit :
Right, I have zero knowledge of C. That would be super if you would be able to replicate the issue in a Windows environment. Admittedly, I don't know what a Windows binary is.

I ran some more tests, based on your suggestion, and also found a couple of links about DOS device paths that proved to be helpful*.

Here are the results -
For each of these Apache would not start:
<IfFile "\\.\Z:">
<IfFile "\\.\Z:\">
<IfFile "\\.\Z:\files\development\ApacheSmokeSignal.txt">
<IfFile "\\.\C:">

For each of these Apache would start whether Z: was connected to the PC or not. However, the code within the <IfFile> tags never executed because localhost:8080/miscellaneous/ always returned a 404 error in the browser.
<IfFile "\\?\Z:">
<IfFile "\\?\Z:\">
<IfFile "\\?\Z:\files\development\ApacheSmokeSignal.txt">
<IfFile "\\?\C:">
<IfFile "\\?\C:\">
<IfFile "\\?\C:\Users\heather.lotz\Documents\_user_files\text.txt">

*For reference, here are links to the useful pages about DOS device paths -
https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats
https://stackoverflow.com/questions/23041983/path-prefixes-and


________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Sent: Friday, August 23, 2019 8:55 AM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?


Hi,


Ok, if you have little knowledge of C, no need to try to apply the patch.

You would need a compiler, some libraries, set-up the environment, configure, build, install...


I'll install a Windows binaries and try your configuration. Should be easy to reproduce.


The syntax you have used is correct (Z:/bla/bla/). AFAIK, the internals of httpd (the APR library to be precise) already translate the '/' (Linux style) in '\' (Windows style).


My proposal was just based on information taken from Microsoft doc (search for "When opening a volume or removable media drive (for example, a floppy disk drive or flash memory thumb drive), ..." near the end of https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew). Because, at some point, on Windows, 'CreteFileW()' is called.




Just 2 words on the patch.

When a configuration file is parsed, when a '<IfFile ...>' directive is found, all lines up to the corresponding </Iffile> are discarded.

To do that the function, we call 'apr_stat()' which gives information on a file (size, name, dates...). In the specific case, no information is requested. This is unusual. Usually we ask for size only, or "standard" information.

The patch just changes the requirement from "do not return anything" to "return size file only".

However, asking for no information *should still work*. The function should tell us that the file exists or not, without any details on the file itself, if found.

My point is that using it this way, is unusual. This could hide a corner case (read: bug in the APR underlying library)


I've had in my todo list for a long time to setup a test environment for Windows. It could be a good occasion to do it. Or you could try with the supplier of a Windows binary (Steffen from Apache lounge is following closely the project and could be of help). Reproduce the issue with their binaries and report to issue to them as well.


Finally, I put back the mailing list in copy, should anyone have an opinion on it

CJ


Le 23/08/2019 ? 14:12, Heather Lotz a ?crit :
Also, it would be helpful to know the expected syntax to use in <IfFile> once the patch is applied.

For instance, does the patch expect
<IfFile "/z/files/development/ApacheSmokeSignal.txt">
and the purpose of the patch is to execute the code within the <IfFile> tags?

Or does the patch expect
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
and the patch will allow the code within the <IfFile> tags to execute as it would on a Linux machine?

I opened the patch file in Notepad++ but don't understand the contents.

________________________________
From: Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Sent: Friday, August 23, 2019 6:44 AM
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Subject: Re: conditionally create a Virtual Host?

Hello Christophe - Thank-you for the reply. Can you please provide some instructions about how to apply the patch?
Heather

________________________________
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr><mailto:christophe.jaillet@wanadoo.fr>
Sent: Friday, August 23, 2019 12:50 AM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>; Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Subject: Re: conditionally create a Virtual Host?

Le 23/08/2019 ? 05:04, Heather Lotz a ?crit :
After some more testing, it seems that this syntax -
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
is the root cause of Apache not starting when the external storage device, mapped to Z:, is detached from the Windows 10 PC.

I tested these variants individually, which are more *nix like -
<IfFile "Z/files/development/ApacheSmokeSignal.txt">
<IfFile "/Z/files/development/ApacheSmokeSignal.txt">
<IfFile "/z/files/development/ApacheSmokeSignal.txt">
and the behavior is Apache starts whether or not Z: is attached to the PC, so that is a step in the right direction. However, the code within the <IfFile> tags never executes because when localhost:8080/miscellaneous/ is entered in a browser it always returns a 404 error.

Another test was this -
<IfFile "/c/Users/heather.lotz/Documents/_user_files/test.txt">
which points to an existing file which is not stored on Z:. The behavior here was the same as that of the 3 *nix like tests. Apache starts whether or not Z: is attached to the PC but code within the <IfFile> tags is not executed because localhost:8080/miscellaneous/ returns a 404 error.

Does this constitute a bug of <IfFile> when used on a Windows OS?

________________________________
From: Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com>
Sent: Wednesday, August 21, 2019 9:36 PM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>
Subject: Re: [users@httpd] conditionally create a Virtual Host?

A new file was created on Z: for the sole purpose of having a designated file for Apache to seek.
The file is called Z:\files\development\ApacheSmokeSignal.txt.

Here is what httpd-vhosts.conf looks like now:
<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
<VirtualHost *:8080>
DocumentRoot "Z:/files/xampp/htdocs"
<Directory "Z:/files/xampp/htdocs">
Options Indexes
Require all granted
</Directory>
</VirtualHost>
</IfFile>

With this update in place, Apache starts fine when Z: is attached to the PC. However, when Z: is not attached to the PC Apache does not start and these lines appear in the XAMPP Control Panel console:
9:30:24 PM [Apache] Attempting to start Apache app...
9:30:24 PM [Apache] Status change detected: running
9:30:26 PM [Apache] Status change detected: stopped
9:30:26 PM [Apache] Error: Apache shutdown unexpectedly.
9:30:26 PM [Apache] This may be due to a blocked port, missing dependencies,
9:30:26 PM [Apache] improper privileges, a crash, or a shutdown by another method.
9:30:26 PM [Apache] Press the Logs button to view error logs and check
9:30:26 PM [Apache] the Windows Event Viewer for more clues
9:30:26 PM [Apache] If you need more help, copy and post this
9:30:26 PM [Apache] entire log window on the forums

There are no entries in error.log with a Wed Aug 21 21:30 or later timestamp.

Is the syntax incorrect? Note that Apache is installed in this location on the PC in question: C:\xampp\apache.

________________________________
From: Eric Covener <covener@gmail.com><mailto:covener@gmail.com>
Sent: Wednesday, August 21, 2019 7:27 PM
To: users@httpd.apache.org<mailto:users@httpd.apache.org> <users@httpd.apache.org><mailto:users@httpd.apache.org>
Subject: Re: [users@httpd] conditionally create a Virtual Host?

On Wed, Aug 21, 2019 at 8:21 PM Heather Lotz <knot22@hotmail.com><mailto:knot22@hotmail.com> wrote:
>
> Greetings,
>
> In my development environment on a Windows 10 PC I have added the following to Apache's configuration files -
>
> To httpd.conf:
> Listen 8080
>
> To httpd-vhosts.conf:
> <VirtualHost *:8080>
> DocumentRoot "Z:/files/xampp/htdocs"
> <Directory "Z:/files/xampp/htdocs">
> Options Indexes
> Require all granted
> </Directory>
> </VirtualHost>
>
> Note that Z: is mapped to an external storage device.
>
> With this setup, Apache successfully accesses C: on port 80 and Z: on port 8080. However, if the external storage device is not attached to the computer, Apache will not start. Is there a way to check if Z: is present, and only create the virtual host if that device is plugged in so that Apache always starts? If so, how can this be achieved?

Try <IfFile> https://httpd.apache.org/docs/2.4/mod/core.html#iffile

--
Eric Covener
covener@gmail.com<mailto:covener@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org<mailto:users-unsubscribe@httpd.apache.org>
For additional commands, e-mail: users-help@httpd.apache.org<mailto:users-help@httpd.apache.org>


Hi,


would you have the opportunity to test the attached patch?

The 0 passed to apr_stat looks spurious to me. (but should work)



(Pure speculation)
Also, based on Microsoft doc, could you also try:

<IfFile "\\.\Z:">
...

and
<IfFile "\\.\Z:\">

...


CJ
Re: Re: conditionally create a Virtual Host? [ In reply to ]
> <IfFile "Z/files/development/ApacheSmokeSignal.txt">

No colon after drive letter?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Re: conditionally create a Virtual Host? [ In reply to ]
Thanks for pointing that out.

<IfFile "Z:/files/development/ApacheSmokeSignal.txt">
works correctly. "Correctly" meaning that Apache starts whether or not the external drive that's mapped to Z: is attached to the PC, localhost:8080/miscellaneous/ resolves when Z: is attached, localhost:8080/miscellaneous/ gives a 404 Not Found response when Z: is not attached.

I also tried
<IfFile "Z:/">
and that works correctly as well.

The tag name "IfFile" implies that the condition given within the tag must be for a specific file but it seems that supplying only the drive letter is sufficient. Will <IfFile> tags work reliably with only the drive letter as the condition as opposed to a specific file?

________________________________
From: Eric Covener <covener@gmail.com>
Sent: Wednesday, January 13, 2021 6:36 PM
To: users@httpd.apache.org <users@httpd.apache.org>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Subject: Re: [users@httpd] Re: conditionally create a Virtual Host?

> <IfFile "Z/files/development/ApacheSmokeSignal.txt">

No colon after drive letter?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Re: conditionally create a Virtual Host? [ In reply to ]
On Wed, Jan 13, 2021 at 8:03 PM Heather Lotz <knot22@hotmail.com> wrote:
>
> Thanks for pointing that out.
>
> <IfFile "Z:/files/development/ApacheSmokeSignal.txt">
> works correctly. "Correctly" meaning that Apache starts whether or not the external drive that's mapped to Z: is attached to the PC, localhost:8080/miscellaneous/ resolves when Z: is attached, localhost:8080/miscellaneous/ gives a 404 Not Found response when Z: is not attached.
>
> I also tried
> <IfFile "Z:/">
> and that works correctly as well.
>
> The tag name "IfFile" implies that the condition given within the tag must be for a specific file but it seems that supplying only the drive letter is sufficient. Will <IfFile> tags work reliably with only the drive letter as the condition as opposed to a specific file?
>

I am not completely sure, but it seems the code evaluates to true when
the parameter is a directory, and c:/ is a directory. While it's not
documented it seems pretty unlikely to be changed.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Re: conditionally create a Virtual Host? [ In reply to ]
Hello,

Apache is a WebServer, that handles "static" content.
With modules Handlers, you can extend this to dynamic
serve like with PHP or Perl.
PHP/Perl are programming Languages, which can be use
to "create" static and/or dynamic output on server
side.
PHP code is written as text file format, and can only
be viewed on server side (if you configured your Web
Server (Apache), and don't having mistakes (Syntax
Errors) in PHP source file.
Because Your PHP (HTML) files consists of static text
or data.
To say the Apache (which serve all content related
stuff) a PHP source file can be a normal text file or
a combination/mixture of HTML, and PHP code - Apache
does all the things what are needed to create a static
WebSite.
This begin with the HTML tag <?php  and end with ?>.
Alle code that resides within this block, are served
by a PHP Handler, that must be configured in the config
file.
With Protocols like GET,POST... you can send requests
or get responses.
Therefore it give AJAX.
AJAX is mostly used by JavaScript Textfiles on Client
side.
JavaScript is a programming Language on Client Side,
which extends the HTML file format for dynamic
content.
To handle the logic of Your WebSite, PHP comes with a
bunch of functions.
So you can programming a PHP script that create/read/
write a database like MySQL, SQLite, etc..
For this (MySQL) it give a DataBase Server, what is
differnt thing as a WebServer like Apache.
A DataBase Server can be used for Desktop Applications
too.
I suggest, "not to have all server service's on one
server machines.", because the maintain..
You can configure Your Apache with differnt Office Open
Times, with differnt "static" WebSites (can be PHP
script or WebServer URL/URI).
You can configure Your Apache, to get/send Header
informations with rewrite_module.
So it is possible to read-out the Browser-Agent what
the user used at serve time Your Apache.
You can configure Your Apache, to have thousends of
Domains, and Subdomains with one IP (without having
bind9 - a Domain Name Server (DNS) installed on Your
server(s)).
You can configure Your Apache to serve WebSites with
thousends ipv6 local IP numbers without having direct
internet connection.
You can configure Your Apache to "protect" content for
display, getting with direct direcives or password per
user, and password in different password file for each
folder or protect folders per ACL groups, ip ranges ...
You can configure Your Apache with differnt DocumentRoot
folders.
I suggest: "not saving htdocs (also all Your content on
Windows drive C:. or under Windows User Home folder. So
you should always use seperate hard disk partition, and
better, not the same disk, and make Backup Your data.
This can be done by Your favorite Backup Software or
(for cheap) github.com like Software which help You to
"save" state's of Your programming process. So it could
be possible to "backport" a Project without override the
old data.".

Hope this help - HTH, Jens



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org