Method: RhaproxyKeywords#reqrep
- Defined in:
- lib/rhaproxy/keywords.rb
#reqrep(params = nil) ⇒ Object
reqrep <search> <string> [(if | unless) <cond>] reqirep <search> <string> [(if | unless) <cond>] (ignore case)
Replace a regular expression with a string in an HTTP request line
May be used in sections : defaults | frontend | listen | backend
no | yes | yes | yes
Arguments :
<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.
<string> is the complete line to be added. Any space or known delimiter
must be escaped using a backslash ('\'). References to matched
pattern groups are possible using the common \N form, with N
being a single digit between 0 and 9. Please refer to section
6 about HTTP header manipulation for more information.
<cond> is an optional matching condition built from ACLs. It makes it
possible to ignore this rule when other conditions are not met.
Any line matching extended regular expression <search> in the request (both
the request line and header lines) will be completely replaced with <string>.
Most common use of this is to rewrite URLs or domain names in "Host" headers.
Header transformations only apply to traffic which passes through HAProxy,
and not to traffic generated by HAProxy, such as health-checks or error
responses. Note that for increased readability, it is suggested to add enough
spaces between the request and the response. Keep in mind that URLs in
request line are case-sensitive while header names are not.
Example :
# replace "/static/" with "/" at the beginning of any request path.
reqrep ^([^\ ]*)\ /static/(.*) \1\ /\2
# replace "www.mydomain.com" with "www" in the host name.
reqirep ^Host:\ www.mydomain.com Host:\ www
See also: "reqadd", "reqdel", "rsprep", section 6 about HTTP header
manipulation, and section 7 about ACLs.
978 979 980 981 982 983 984 985 |
# File 'lib/rhaproxy/keywords.rb', line 978 def reqrep(params = nil) if @name_index @conf.insert(@name_index + @conf.length, " " + "reqrep " + params.to_s + "\n") else puts "no #{@proxy_type} name assigned" return false end end |