Re: Variable of document root path based on source ip

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 3, 2022 at 5:44 PM Yann Ylavic <ylavic.dev@xxxxxxxxx> wrote:
>
> On Mon, May 2, 2022 at 8:24 AM Ivan Ionut <ivan.ionut@xxxxxxxxxxxxxx> wrote:
> >
> > I'm trying to set a virtual host on apache2 with this configuration.
> >
> > <VirtualHost *:80>
> >   ServerName mysite.com
> >   ServerAlias www.mysite.com
> >
> >   <If "-R '192.168.1.0/24'">
> >     Define directory_path /srv/http/mysite
> >   </If>
> >   <Else>
> >     Define directory_path /srv/http/under_construction
> >   </Else>
> >
> > DocumentRoot ${directory_path}
> >
> > <Directory ${directory_path}>
> > Require all granted
> > </Directory>
> > </VirtualHost>
> >
> > The problem is that the If directive does not match when I access it from that lan.
>
> Possibly something like this could work:
>
> Define directory_path_mysite "/srv/http/mysite"
> Define directory_path_under_construction "/srv/http/under_construction"
> <VirtualHost *:80>
>   <If "-R '192.168.1.0/24'">
>     DocumentRoot "${directory_path_mysite}"
>   <Else>
>     DocumentRoot "$(directory_path_under_construction}"
>   </If>

But DocumentRoot might not be allowed in an <If section..

>   <Directory "${directory_path_mysite}">
>     Require all granted
>   </Directory>
>   <Directory "${directory_path_under_construction}">
>     Require all granted
>   </Directory>
> </VirtualHost>
>
> Both DocumentRoots would be initialized at startup (when Defines are
> evaluated, the <Directory paths must be known then), while the
> DocumentRoot used at runtime will be determined based on the <If
> still.
>
>
> Regards;
> Yann.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx




[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux