I'm confused by what I read at 
http://cbonte.github.io/haproxy-dconv/configuration-1.6.html#4.2-reqirep:



<search>  is the regular expression applied to HTTP headers and to the

          request line. This is an extended regular expression. Parenthesis

          grouping is supported and no preliminary backslash is required.

          Any space or known delimiter must be escaped using a backslash

          ('\'). The pattern applies to a full line at a time. The "reqrep"

          keyword strictly matches case while "reqirep" ignores case.





The second I used match also "Referer:..."

reqirep (.*)\/demoj(.*)     \1/DemoJ\2                                          
      -> applied to headers, this regex should match and subst correctly also 
for "Referer: ....."... I'm wrong ?





I get it to work using 2 different regex. The second matching statically 
"Referer..."



reqirep (.*)\/demoj(.*)     \1/DemoJ\2                                          
      -> I thought it was applied also to headers, this regex match and subst 
correctly also for "Referer: ....."

reqirep ^Referer:(.*)\/demoj(.*)   Referer:\1/DemoJ\2                           
  -> this change Referer









Roberto





-----Original Message-----
From: Cyril Bonté [mailto:cyril.bo...@free.fr]
Sent: lunedì 27 luglio 2015 19.49
To: mlist; haproxy@formilux.org
Cc: Willy Tarreau; 'Baptiste'
Subject: Re: Regex



Hi,



Le 27/07/2015 17:06, mlist a écrit :

> Hi Aleksandar,



Please, when you start a new thread, try to send it to the the mailing

list instead of adding by default some users who helped you in the past

(and btw, Aleksandar was not in the recipients).



> I'm compiled with USE_PCRE=yes flag. At 
> http://cbonte.github.io/haproxy-dconv/configuration-1.6.html#4.2-reqirep

> In the example

> replace /static/" with "/" at the beginning of any request path.

>

>             reqrep ^([^\ :]*)\ /static/(.*)     \1\ /\2"

>

> I changed the regex with this:

>

> (1)      reqirep ^([^\ :]*)\ /demoj(.*)     \1\ /DemoJ\2

>

> and also to this more simple (for my regex acknoledge)...:

>

> (2)      reqirep (.*)\/demoj(.*)     \1/DemoJ\2

>

> The redirection work well for the request line, but I cannot see change in 
> the request header "Referer:" as example, as you can see below

>

> GET  /DemoJ/img/entra.gif;jsessionid=21DC3F99E5604CC9AD8482CCA9286B65 HTTP/1.1

> Host: demo.hypersic.net

> ...

> Referer: https://demo.mydomain.net/dEmOj/

> ...

>

>

> So the client can connect correctly also if it enter wrong case, but in the 
> Browser URL often remain in wrong case.

> Can you help me ?



Indeed, look at the regex, it's not designed to match the Referer.

This one would match :

Referer: /dEmOj/



As an exercise, you can try to find a regex that will apply to both the

request line and the Referer header, or manage 2 distinct regex

replacements.



--

Cyril Bonté



--

Il messaggio e' stato analizzato alla ricerca di virus o

contenuti pericolosi da MailScanner, ed e'

risultato non infetto.


Reply via email to