Response Body Injection
The Response Body Injection (RBI) module allows you to insert content into an HTTP response before it is sent back to the client. It can insert content into any of the following HTML sections:
Install the RBI module
Install the RBI module as follows, depending on your platform:
$ # On Debian/Ubuntu $ sudo apt-get install hapee-1.8r2-lb-htmldom
$ # On CentOS/RedHat/Oracle $ sudo yum install hapee-1.8r2-lb-htmldom
globalsection of your HAProxy Enterprise configuration file, add a
global module-load hapee-lb-htmldom.so
filter htmldomdirective to a
backendsection to begin injecting content.
<script>tag inside the
The script does the work of updating the links on the page.
A closer examination of the script will give you more details about how it works.
When you insert a large amount of content into a response, be sure to set
globalsection to the appropriate size.
The RBI filter automatically deactivates under certain conditions, including:
the request method is HEAD;
both request and response are HTTP/1.1, but the Transfer-Encoding header value is not chunked and Content-Length is unknown;
the response is compressed (i.e. the Content-Encoding header is present);
the response contains the Cache-Control header set to no-transform (no transformations or conversions can happen);
the Content-Type header is set to a value other than text/html;
Also, note that:
you can only use one
htmldomfilter per listener/frontend/backend.
due to the current limitation of the filter's implementation, we do not recommended that you use this filter in combination with other filters that modify the response on the same listener/frontend/backend. Using them can cause undefined behavior (for example, the compression filter).
if you encounter problems with the response body manipulation, check your HAProxy Enterprise logs. The RBI filter logs problems related to the buffer operations, such as initialization and manipulation.
Changed HTTP headers
filter htmldom directive modifies the response in the following ways:
It removes all occurrences of the Accept-Encoding header from the incoming request to ensure that the response does not get compressed.
It removes all occurrences of the Content-Length header in order to modify the response.
If the message is HTTP/1.1 or above, it sets the Transfer-Encoding header to chunked.
filter htmldom directive instructs HAProxy Enterprise to inject content into an HTML document. You can declare it only once for each proxy section. Its syntax is:
# Used in the a frontend, listen, or backend section filter htmldom [mode <mode>] <action> <content>
| || |
Sets the HTML parser in either of these modes:
| || |
Identifies the HTML element in which to inject new content. It applies to the first matching element. Valid actions are:
| || |
The HTML content to inject into the response from a server. It is a
Next upSession Persistence