You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Marc <Ma...@f1-outsourcing.eu> on 2024/02/27 20:47:34 UTC

[users@httpd] working with a reverse proxy

I am having a more or less default setup where I proxy a website with something like this

ProxyPass        "https://${proxyhost}/en_gb"
ProxyPassReverse "https://${proxyhost}/en_gb"

ProxyPassReverseCookieDomain "${proxyhost}" "${defaulthost}"

ProxyHTMLURLMap ... 
ProxyHTMLURLMap ..

Everything on the default host seems to work quite well and you can navigate all pages that are proxied.

The issue that I have is that the proxied website at some point does an api request to an external host, sending it's hostname. I want it to send the hostname of the defaulthost, not the proxyhost. 

What would a best practice of 'informing' the proxyhost about that it is being proxied and it should send the defaulthost hostname?

Should I for instance set headers, and in the proxied website should I check on such headers? (Btw this is php). Or are there other things available like HTTP_X_FORWARDED_FOR



RE: [users@httpd] working with a reverse proxy

Posted by Marc <Ma...@f1-outsourcing.eu>.

> > Should I for instance set headers, and in the proxied website should I
> check on such headers? (Btw this is php). Or are there other things
> available like HTTP_X_FORWARDED_FOR
> 
> mod_proxy should add the "X-Forwarded-Host" header (i.e.
> HTTP_X_FORWARDED_HOST in cgi/php) with the value of defaulthost, when
> forwarding the request to proxyhost. This is the default behaviour,
> unless "ProxyAddHeaders off".
> 


Thanks Yann! I was looking indeed at the wrong headers, these two are having the correct value.

[HTTP_X_FORWARDED_SERVER] 
[HTTP_X_FORWARDED_HOST]

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

Re: [users@httpd] working with a reverse proxy

Posted by Yann Ylavic <yl...@gmail.com>.
On Tue, Feb 27, 2024 at 9:49 PM Marc <Ma...@f1-outsourcing.eu> wrote:
>
> Should I for instance set headers, and in the proxied website should I check on such headers? (Btw this is php). Or are there other things available like HTTP_X_FORWARDED_FOR

mod_proxy should add the "X-Forwarded-Host" header (i.e.
HTTP_X_FORWARDED_HOST in cgi/php) with the value of defaulthost, when
forwarding the request to proxyhost. This is the default behaviour,
unless "ProxyAddHeaders off".


Regards;
Yann.

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


RE: [users@httpd] working with a reverse proxy

Posted by Marc <Ma...@f1-outsourcing.eu>.
> 
> 
> 	>
> 	> > What would a best practice of 'informing' the proxyhost about that
> it is
> 	> being proxied and it should send the defaulthost hostname?
> 	>
> 	> can try
> 	>
> https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypreservehost
> 
> 	Proxy only works when I am having ProxyPreserveHost Off, I can't
> change that.
> 
> 
> What happens when you use ProxyPreserveHost, exactly?

I am getting a 'Content Encoding Error'. I think this proxied web application by default is doing some routing based on host names. 

Re: [users@httpd] working with a reverse proxy

Posted by Frank Gingras <th...@apache.org>.
On Tue, Feb 27, 2024 at 5:10 PM Marc <Ma...@f1-outsourcing.eu> wrote:

>
> >
> > > What would a best practice of 'informing' the proxyhost about that it
> is
> > being proxied and it should send the defaulthost hostname?
> >
> > can try
> > https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypreservehost
>
> Proxy only works when I am having ProxyPreserveHost Off, I can't change
> that.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org


What happens when you use ProxyPreserveHost, exactly?

RE: [users@httpd] working with a reverse proxy

Posted by Marc <Ma...@f1-outsourcing.eu>.
> 
> > What would a best practice of 'informing' the proxyhost about that it is
> being proxied and it should send the defaulthost hostname?
> 
> can try
> https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypreservehost

Proxy only works when I am having ProxyPreserveHost Off, I can't change that.


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

Re: [users@httpd] working with a reverse proxy

Posted by Eric Covener <co...@gmail.com>.
> What would a best practice of 'informing' the proxyhost about that it is being proxied and it should send the defaulthost hostname?

can try https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypreservehost

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