You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Tom Browder <to...@gmail.com> on 2020/01/24 18:06:20 UTC
[users@httpd] Virtual host macros and reverse proxy
I have multiple virtual hosts for which I would like to use a reverse proxy
to a dynamic application running constantly on my server.
I would like to use a macro to do something like this pseudo code:
$port = 16000
for each domain.tld
map domain.tld to localhost:$port
$port += 10
end for
Is that possible?
Otherwise I guess I can generate the required .conf files offline and
include them in the master .conf file somehow.
Thanks.
-Tom
Re: [users@httpd] Re: Virtual host macros and reverse proxy
Posted by Tom Browder <to...@gmail.com>.
On Wed, Jan 29, 2020 at 10:25 AM Gillis J. de Nijs
<gi...@jink.net.invalid> wrote:
> <If> works at request time, so that might be useful for picking the port to forward to, but in my opinion it's not that useful for creating a configuration. For example, it wouldn't allow you to choose the ports to listen on. I'm also not sure it would work correctly with ProxyPass and ProxyPassReverse. I'd probably just use mod_macro, or generate the configuration offline.
I've modified the macro to use reverse proxies. Take a look at this:
https://github.com/tbrowder/apache-httpd-tidbits/blob/master/conf/vhost-proxy.macro.conf
-Tom
> On Wed, Jan 29, 2020 at 4:05 PM Tom Browder <to...@gmail.com> wrote:
>>
>> On Wed, Jan 29, 2020 at 08:36 Gillis J. de Nijs <gi...@jink.net.invalid> wrote:
>> >
>> > There's mod_macro that might be useful. I don't think it does calculations, though, so you might need to do some things yourself. Maybe you could indeed generate the conf files yourself and use Include or IncludeOptional.
>>
>> ...
>>
>> Thanks, Gillis. After I "pinged" this morning I checked the docs again
>> and I think I can use if/else directives inside the macro, something
>> like this pseudo code:
>>
>> <if domain.tld = foo.org>
>> $port = 16000
>> </if>
>> <elseif domain.tld = bar.com>
>> $port = 16100
>> </elsif>
>> <else>
>> $port = 16800
>> </else>
>>
>> What do you think?
>>
>> -Tom
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Re: Virtual host macros and reverse proxy
Posted by "Gillis J. de Nijs" <gi...@jink.net.INVALID>.
<If> <https://httpd.apache.org/docs/2.4/mod/core.html#if> works at request
time, so that might be useful for picking the port to forward to, but in my
opinion it's not that useful for creating a configuration. For example, it
wouldn't allow you to choose the ports to listen on. I'm also not sure it
would work correctly with ProxyPass
<https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypass> and
ProxyPassReverse
<https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypassreverse>.
I'd probably just use mod_macro, or generate the configuration offline.
On Wed, Jan 29, 2020 at 4:05 PM Tom Browder <to...@gmail.com> wrote:
> On Wed, Jan 29, 2020 at 08:36 Gillis J. de Nijs <gi...@jink.net.invalid>
> wrote:
> >
> > There's mod_macro that might be useful. I don't think it does
> calculations, though, so you might need to do some things yourself. Maybe
> you could indeed generate the conf files yourself and use Include or
> IncludeOptional.
>
> ...
>
> Thanks, Gillis. After I "pinged" this morning I checked the docs again
> and I think I can use if/else directives inside the macro, something
> like this pseudo code:
>
> <if domain.tld = foo.org>
> $port = 16000
> </if>
> <elseif domain.tld = bar.com>
> $port = 16100
> </elsif>
> <else>
> $port = 16800
> </else>
>
> What do you think?
>
> -Tom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
Re: [users@httpd] Re: Virtual host macros and reverse proxy
Posted by Tom Browder <to...@gmail.com>.
On Wed, Jan 29, 2020 at 08:36 Gillis J. de Nijs <gi...@jink.net.invalid> wrote:
>
> There's mod_macro that might be useful. I don't think it does calculations, though, so you might need to do some things yourself. Maybe you could indeed generate the conf files yourself and use Include or IncludeOptional.
...
Thanks, Gillis. After I "pinged" this morning I checked the docs again
and I think I can use if/else directives inside the macro, something
like this pseudo code:
<if domain.tld = foo.org>
$port = 16000
</if>
<elseif domain.tld = bar.com>
$port = 16100
</elsif>
<else>
$port = 16800
</else>
What do you think?
-Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Re: Virtual host macros and reverse proxy
Posted by "Gillis J. de Nijs" <gi...@jink.net.INVALID>.
There's mod_macro <https://httpd.apache.org/docs/2.4/mod/mod_macro.html>
that might be useful. I don't think it does calculations, though, so you
might need to do some things yourself. Maybe you could indeed generate the
conf files yourself and use Include
<https://httpd.apache.org/docs/2.4/mod/core.html#include> or IncludeOptional
<https://httpd.apache.org/docs/2.4/mod/core.html#includeoptional>.
I'd like to note that generating port numbers based on domains might work,
at first, but if you delete a domain from the list, the numbers will
shift. So, a=>16010, b=>16020, c=>16030, etc, becomes a=>16010, c=>16020,
for example.
For doing the actual reverse proxying, you should probably read this
<https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html> and/or this
<http://www.apachetutor.org/admin/reverseproxies>.
>
[users@httpd] Re: Virtual host macros and reverse proxy
Posted by Tom Browder <to...@gmail.com>.
On Fri, Jan 24, 2020 at 12:06 Tom Browder <to...@gmail.com> wrote:
> I have multiple virtual hosts for which I would like to use a reverse
> proxy to a dynamic application running constantly on my server.
>
...
Ping