Help configure a Reverse proxy with Substitute

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Help configure a Reverse proxy with Substitute

Flaviu Radulescu

Dear community,

 

I need an advice on how to configure a reverse proxy in which I need to replace the <img src=""> tag from the response html with an ENV variable defined previously. How do you recommend me to do this?

 

I tried with substitute, but unfortunately doesn't seem to support variables.

 

The variable I am setting with the command: SetEnvIf Request_URI "/lp\/([a-zA-Z0-9]*)" st=$1.example.com

 

and now I would like to use the {st} variable in the substitute

 

Substitute "s|src=\"(.*?)\"|src=\"%{st}e/lp/$1\"|i"

I tried with %{st}e , ${st} in any combination it doesn't work.

 

Is there any way in which I can use e previous defined variable in rewriting the proxy response HTML?

 

Thank you,

 

---

FLAVIU RADULESCU | Lumminary  |  lumminary.comhttps://lumminary.com/1x1.png?t=flv-otlk


PLEASE NOTE:  This email and any file transmitted are confidential and/or legally privileged and intended only for the person(s) directly addressed. If you are not the intended recipient, any use, copying, transmission, distribution, or other forms of dissemination is strictly prohibited. If you have received this email in error, please notify the sender immediately and permanently delete the email and files, if any.

 

Reply | Threaded
Open this post in threaded view
|

RE: Help configure a Reverse proxy with Substitute

Muggeridge, Matt

See the documentation on mod_substitute.html.  It describes that if you want to access environment variables, then the substitution must begin with ‘expr=’.

 

The doc provides an example for substituting with variables:

 

Expression Example

<Location "/">

    AddOutputFilterByType SUBSTITUTE text/html

    Substitute "s/example.com/expr=%{HTTP:HOST}/i"

    Substitute "s/Hello, (\S+)/expr=Hello from %{REQUEST_URI}, \$1/i"

</Location>

 

Hazarding a guess, you could try prefixing your substituted string with ‘expr=’, as follows:

 

 

Substitute "s|src=\"(.*?)\"|expr=src=\"%{st}e/lp/$1\"|i"

 

 

I’m just reading from the docs and have not tried it myself.

 

Matt.

 

From: Flaviu Radulescu <[hidden email]>
Sent: Friday, 15 March 2019 7:47 PM
To: [hidden email]
Subject: Help configure a Reverse proxy with Substitute

 

Dear community,

 

I need an advice on how to configure a reverse proxy in which I need to replace the <img src=""> tag from the response html with an ENV variable defined previously. How do you recommend me to do this?

 

I tried with substitute, but unfortunately doesn't seem to support variables.

 

The variable I am setting with the command: SetEnvIf Request_URI "/lp\/([a-zA-Z0-9]*)" st=$1.example.com

 

and now I would like to use the {st} variable in the substitute

 

Substitute "s|src=\"(.*?)\"|src=\"%{st}e/lp/$1\"|i"

I tried with %{st}e , ${st} in any combination it doesn't work.

 

Is there any way in which I can use e previous defined variable in rewriting the proxy response HTML?

 

Thank you,

 

---

FLAVIU RADULESCU | Lumminary  |  lumminary.comImage removed by sender. https://lumminary.com/1x1.png?t=flv-otlk


PLEASE NOTE:  This email and any file transmitted are confidential and/or legally privileged and intended only for the person(s) directly addressed. If you are not the intended recipient, any use, copying, transmission, distribution, or other forms of dissemination is strictly prohibited. If you have received this email in error, please notify the sender immediately and permanently delete the email and files, if any.

 

Reply | Threaded
Open this post in threaded view
|

RE: Help configure a Reverse proxy with Substitute

Luis Speciale
Le 18/03/2019 à 18:36, Muggeridge, Matt a écrit :
> See the documentation on mod_substitute.html

I was following this thread and the doc says

"expr=" substitution values were added in 2.5.1

But my install is /2.4.38. I have installed it with brew on a Mac but I
can't find a dev version. What can I do? Must I install it from source?

Thanks in advance

Luis

> <https://httpd.apache.org/docs/trunk/en/mod/mod_substitute.html>.  It
> describes that if you want to access environment variables, then the
> substitution must begin with ‘expr=’.
>
> The doc provides an example for substituting with variables:
>
> *Expression Example*
>
> <*Location*"/">
>
> *AddOutputFilterByType*SUBSTITUTE text/html
>
> *Substitute*"s/example.com/expr=%{HTTP:HOST}/i"
>
> *Substitute*"s/Hello, (\S+)/expr=Hello from %{REQUEST_URI}, \$1/i"
>
> </*Location*>
>
> Hazarding a guess, you could try prefixing your substituted string with
> ‘expr=’, as follows:
>
> *Substitute*"s|src=\"(.*?)\"|expr=src=\"%{st}e/lp/$1\"|i"
>
> I’m just reading from the docs and have not tried it myself.
>
> Matt.
>
> *From:*Flaviu Radulescu <[hidden email]>
> *Sent:* Friday, 15 March 2019 7:47 PM
> *To:* [hidden email]
> *Subject:* Help configure a Reverse proxy with Substitute
>
> Dear community,
>
> I need an advice on how to configure a reverse proxy in which I need to
> replace the <img src=""> tag from the response html with an ENV variable
> defined previously. How do you recommend me to do this?
>
> I tried with substitute, but unfortunately doesn't seem to support
> variables.
>
> The variable I am setting with the command: SetEnvIf Request_URI
> "/lp\/([a-zA-Z0-9]*)" st=$1.example.com
>
> and now I would like to use the {st} variable in the substitute
>
> Substitute "s|src=\"(.*?)\"|src=\"%{st}e/lp/$1\"|i"
>
> I tried with %{st}e , ${st} in any combination it doesn't work.
>
> Is there any way in which I can use e previous defined variable in
> rewriting the proxy response HTML?
>
> Thank you,
>
> **
>
> *---*
>
> *FLAVIU RADULESCU***| Lumminary | lumminary.com
> <https://lumminary.com/>Image removed by sender.
> https://lumminary.com/1x1.png?t=flv-otlk
>
>
> PLEASE NOTE:  This email and any file transmitted are confidential
> and/or legally privileged and intended only for the person(s) directly
> addressed. If you are not the intended recipient, any use, copying,
> transmission, distribution, or other forms of dissemination is strictly
> prohibited. If you have received this email in error, please notify the
> sender immediately and permanently delete the email and files, if any.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Help configure a Reverse proxy with Substitute

Marion & Christophe JAILLET
In reply to this post by Flaviu Radulescu
Le 15/03/2019 à 10:47, Flaviu Radulescu a écrit :

Dear community,

 

I need an advice on how to configure a reverse proxy in which I need to replace the <img src=""> tag from the response html with an ENV variable defined previously. How do you recommend me to do this?

 

I tried with substitute, but unfortunately doesn't seem to support variables.

 

The variable I am setting with the command: SetEnvIf Request_URI "/lp\/([a-zA-Z0-9]*)" st=$1.example.com

 

and now I would like to use the {st} variable in the substitute

 

Substitute "s|src=\"(.*?)\"|src=\"%{st}e/lp/$1\"|i"

I tried with %{st}e , ${st} in any combination it doesn't work.

 

Is there any way in which I can use e previous defined variable in rewriting the proxy response HTML?

 

Thank you,

 

---

FLAVIU RADULESCU | Lumminary  |  lumminary.comhttps://lumminary.com/1x1.png?t=flv-otlk


PLEASE NOTE:  This email and any file transmitted are confidential and/or legally privileged and intended only for the person(s) directly addressed. If you are not the intended recipient, any use, copying, transmission, distribution, or other forms of dissemination is strictly prohibited. If you have received this email in error, please notify the sender immediately and permanently delete the email and files, if any.

 

Hi,

you could have a look at mod_proxy_html.

The 'V' flag of the ProxyHTMLURLMap directive (with "ProxyHTMLInterp On" and something like "ProxyHTMLLinks img src") should do what you are looking for.

CJ