diff --git a/doc/configuration.txt b/doc/configuration.txt index 42efa329e..6f61e2660 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -4424,14 +4424,12 @@ clitcpka-intvl compression algo ... compression type ... -compression offload Enable HTTP compression. May be used in sections : defaults | frontend | listen | backend yes | yes | yes | yes Arguments : algo is followed by the list of supported compression algorithms. type is followed by the list of MIME types that will be compressed. - offload makes HAProxy work as a compression offloader only (see notes). The currently supported algorithms are : identity this is mostly for debugging, and it was useful for developing @@ -4465,19 +4463,6 @@ compression offload there is Accept-Encoding header in request, HAProxy will compress the matching response. - The "offload" setting makes HAProxy remove the Accept-Encoding header to - prevent backend servers from compressing responses. It is strongly - recommended not to do this because this means that all the compression work - will be done on the single point where HAProxy is located. However in some - deployment scenarios, HAProxy may be installed in front of a buggy gateway - with broken HTTP compression implementation which can't be turned off. - In that case HAProxy can be used to prevent that gateway from emitting - invalid payloads. In this case, simply removing the header in the - configuration does not work because it applies before the header is parsed, - so that prevents HAProxy from compressing. The "offload" setting should - then be used for such scenarios. Note: for now, the "offload" setting is - ignored when set in a defaults section. - Compression is disabled when: * the request does not advertise a supported compression algorithm in the "Accept-Encoding" header @@ -4501,6 +4486,29 @@ compression offload compression algo gzip compression type text/html text/plain + See also : "compression offload" + +compression offload + Makes HAProxy work as a compression offloader only. + May be used in sections : defaults | frontend | listen | backend + no | yes | yes | yes + + The "offload" setting makes HAProxy remove the Accept-Encoding header to + prevent backend servers from compressing responses. It is strongly + recommended not to do this because this means that all the compression work + will be done on the single point where HAProxy is located. However in some + deployment scenarios, HAProxy may be installed in front of a buggy gateway + with broken HTTP compression implementation which can't be turned off. + In that case HAProxy can be used to prevent that gateway from emitting + invalid payloads. In this case, simply removing the header in the + configuration does not work because it applies before the header is parsed, + so that prevents HAProxy from compressing. The "offload" setting should + then be used for such scenarios. + + If this setting is used in a defaults section, a warning is emitted and the + option is ignored. + + See also : "compression type", "compression algo" cookie [ rewrite | insert | prefix ] [ indirect ] [ nocache ] [ postonly ] [ preserve ] [ httponly ] [ secure ] diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c index 9d8c3fa64..f2b210a67 100644 --- a/src/flt_http_comp.c +++ b/src/flt_http_comp.c @@ -631,6 +631,7 @@ parse_compression_options(char **args, int section, struct proxy *proxy, char **err) { struct comp *comp; + int ret = 0; if (proxy->comp == NULL) { comp = calloc(1, sizeof(*comp)); @@ -644,58 +645,71 @@ parse_compression_options(char **args, int section, struct proxy *proxy, int cur_arg = 2; if (!*args[cur_arg]) { - memprintf(err, "parsing [%s:%d] : '%s' expects \n", + memprintf(err, "parsing [%s:%d] : '%s' expects .", file, line, args[0]); - return -1; + ret = -1; + goto end; } while (*(args[cur_arg])) { int retval = comp_append_algo(comp, args[cur_arg]); if (retval) { if (retval < 0) - memprintf(err, "'%s' : '%s' is not a supported algorithm.\n", + memprintf(err, "'%s' : '%s' is not a supported algorithm.", args[0], args[cur_arg]); else - memprintf(err, "'%s' : out of memory while parsing algo '%s'.\n", + memprintf(err, "'%s' : out of memory while parsing algo '%s'.", args[0], args[cur_arg]); - return -1; + ret = -1; + goto end; } if (proxy->comp->algos->init(&ctx, 9) == 0) proxy->comp->algos->end(&ctx); else { - memprintf(err, "'%s' : Can't init '%s' algorithm.\n", + memprintf(err, "'%s' : Can't init '%s' algorithm.", args[0], args[cur_arg]); - return -1; + ret = -1; + goto end; } cur_arg++; continue; } } - else if (strcmp(args[1], "offload") == 0) + else if (strcmp(args[1], "offload") == 0) { + if (proxy->cap & PR_CAP_DEF) { + memprintf(err, "'%s' : '%s' ignored in 'defaults' section.", + args[0], args[1]); + ret = 1; + } comp->offload = 1; + } else if (strcmp(args[1], "type") == 0) { int cur_arg = 2; if (!*args[cur_arg]) { - memprintf(err, "'%s' expects \n", args[0]); - return -1; + memprintf(err, "'%s' expects .", args[0]); + ret = -1; + goto end; } while (*(args[cur_arg])) { if (comp_append_type(comp, args[cur_arg])) { memprintf(err, "'%s': out of memory.", args[0]); - return -1; + ret = -1; + goto end; } cur_arg++; continue; } } else { - memprintf(err, "'%s' expects 'algo', 'type' or 'offload'\n", + memprintf(err, "'%s' expects 'algo', 'type' or 'offload'", args[0]); - return -1; + ret = -1; + goto end; } - return 0; + end: + return ret; } static int