MEDIUM: http-rules: Add the return action to HTTP rules
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 24 Jan 2020 16:44:23 +0000 (17:44 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 6 Feb 2020 14:12:54 +0000 (15:12 +0100)
commit24231ab61f8a21a5a087989fe25f68df43ea25c7
tree1b94cb42e826220ff65c84020234bfc14c23fa7e
parent6d0c3dfac643d21478793759927dc7cfb8b1b3cd
MEDIUM: http-rules: Add the return action to HTTP rules

Thanks to this new action, it is now possible to return any responses from
HAProxy, with any status code, based on an errorfile, a file or a string. Unlike
the other internal messages generated by HAProxy, these ones are not interpreted
as errors. And it is not necessary to use a file containing a full HTTP
response, although it is still possible. In addition, using a log-format string
or a log-format file, it is possible to have responses with a dynamic
content. This action can be used on the request path or the response path. The
only constraint is to have a responses smaller than a buffer. And to avoid any
warning the buffer space reserved to the headers rewritting should also be free.

When a response is returned with a file or a string as payload, it only contains
the content-length header and the content-type header, if applicable. Here are
examples:

  http-request return content-type image/x-icon file /var/www/favicon.ico  \
      if { path /favicon.ico }

  http-request return status 403 content-type text/plain    \
      lf-string "Access denied. IP %[src] is blacklisted."  \
      if { src -f /etc/haproxy/blacklist.lst }
doc/configuration.txt
include/types/action.h
src/http_act.c