Re: Re: mod_rewrite: Conditionally set RemoteIPHeader

Eric Covener <[email protected]> Wed, 11 Jun 2025 21:19:46 -0400
Newsgroups gmane.comp.apache.user
Message-ID <CALK=YjNV5u7tTnNU2qevEcnLXJSbwiH_ELri6Ss1C5UfPGo=+w@mail.gmail.com>
On Wed, Jun 11, 2025 at 6:48 PM <[email protected]> wrote:
>
> Does anyone know of a way to conditionally set the RemoteIPHeader
> directive for mod_remoteip? I've tried a few things; a simple if/else
> says "RemoteIPHeader is not allowed here." And trying to set my own
> request header that I can point "RemoteIPHeader" to doesn't seem to
> work; no matter how I order it or create it it seems that RemoteIPHeader
> doesn't recognize the new header I've generated.
>
> Any ideas?
>
> Thanks in advance!

Doesn't look viable. mod_remoteip does its work very early during
ap_run_post_read_request() which happens before things like If or
other configuration sections have been processed or even mod_setenvif
rules without the obscure --early flag.

I think you'd have to extend the module such that RemoteIPHeader could
accept an expression that is evaluated (like e.g. mod_headers values
of expr=or setenvifexpr