Re: Rewrite image path based on HTTP_REQUEST

2018-05-23 Thread Jarno Huuskonen
Hi,

On Sat, May 19, Aleksandar Lazic wrote:
> On 17/05/2018, Lotic Lists wrote:
> > How can I rewrite a image path based on URL?
> > 
> > Example, users request the url www.example.com/images/logo.png, haproxy just
> > balance to backend servers normally.
> > 
> > Now users request www.newdomain.com, I need rewrite URI to
> > /images/new-logo.png
> 
> Well what have you already tried?
> 
> I would try, untested.
> 
> https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#4.2-reqrep
> 
> acl old_dom hdr(host) -i www.example.com
> acl old_path path_beg -i /images/logo.png
> 
> reqrep "^([^ :]*) /images/logo.png /images/new-logo.png" if old_dom && 
> old_path
> reqirep "^Host: www.example.com   "Host: www.newdomain.com" if old_dom && 
> old_path

If you just need to change the path then http-request set-path should be
enough(https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#4-http-request).

Something like:
acl new_dom hdr_dom(host) -i www.newdomain.com
acl old_path path_beg -i /images/logo.png
http-request set-path "/images/new-logo.png" if new_dom old_path

-Jarno

-- 
Jarno Huuskonen - System Administrator |  jarno.huuskonen atsign uef.fi



Re: Rewrite image path based on HTTP_REQUEST

2018-05-18 Thread Aleksandar Lazic
On 17/05/2018, Lotic Lists wrote:
> Hi experts
> 
> How can I rewrite a image path based on URL?
> 
> Example, users request the url www.example.com/images/logo.png, haproxy just
> balance to backend servers normally.
> 
> Now users request www.newdomain.com, I need rewrite URI to
> /images/new-logo.png

Well what have you already tried?

I would try, untested.

https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#4.2-reqrep

acl old_dom hdr(host) -i www.example.com
acl old_path path_beg -i /images/logo.png

reqrep "^([^ :]*) /images/logo.png /images/new-logo.png" if old_dom && old_path
reqirep "^Host: www.example.com   "Host: www.newdomain.com" if old_dom && 
old_path

> Tks.
> 
> Marcelo

Regards
Aleks