Welcome! Log In Create A New Profile

Advanced

Re: [PATCH 10 of 14] Proxy: always emit "Host" header first

Maxim Dounin
July 04, 2017 12:50PM
Hello!

On Thu, Jun 22, 2017 at 01:33:14PM -0700, Piotr Sikora via nginx-devel wrote:

> # HG changeset patch
> # User Piotr Sikora <piotrsikora@google.com>
> # Date 1489618489 25200
> # Wed Mar 15 15:54:49 2017 -0700
> # Node ID 068381014f256ad6e2dc490bacc2529cebbb0462
> # Parent 96075d4cd2a6e8bd67caf1d7b78f8e87d757c48d
> Proxy: always emit "Host" header first.
>
> Signed-off-by: Piotr Sikora <piotrsikora@google.com>
>
> diff -r 96075d4cd2a6 -r 068381014f25 src/http/modules/ngx_http_proxy_module.c
> --- a/src/http/modules/ngx_http_proxy_module.c
> +++ b/src/http/modules/ngx_http_proxy_module.c
> @@ -3422,7 +3422,7 @@ ngx_http_proxy_init_headers(ngx_conf_t *
> uintptr_t *code;
> ngx_uint_t i;
> ngx_array_t headers_names, headers_merged;
> - ngx_keyval_t *src, *s, *h;
> + ngx_keyval_t *host, *src, *s, *h;
> ngx_hash_key_t *hk;
> ngx_hash_init_t hash;
> ngx_http_script_compile_t sc;
> @@ -3454,11 +3454,33 @@ ngx_http_proxy_init_headers(ngx_conf_t *
> return NGX_ERROR;
> }
>
> + h = default_headers;
> +
> + if (h->key.len != sizeof("Host") - 1
> + || ngx_strcasecmp(h->key.data, (u_char *) "Host") != 0)
> + {
> + return NGX_ERROR;
> + }
> +
> + host = ngx_array_push(&headers_merged);
> + if (host == NULL) {
> + return NGX_ERROR;
> + }
> +
> + *host = *h++;
> +
> if (conf->headers_source) {
>
> src = conf->headers_source->elts;
> for (i = 0; i < conf->headers_source->nelts; i++) {
>
> + if (src[i].key.len == sizeof("Host") - 1
> + && ngx_strcasecmp(src[i].key.data, (u_char *) "Host") == 0)
> + {
> + *host = src[i];
> + continue;
> + }
> +
> s = ngx_array_push(&headers_merged);
> if (s == NULL) {
> return NGX_ERROR;
> @@ -3468,8 +3490,6 @@ ngx_http_proxy_init_headers(ngx_conf_t *
> }
> }
>
> - h = default_headers;
> -
> while (h->key.len) {
>
> src = headers_merged.elts;

As already outlined in the review here:

http://mailman.nginx.org/pipermail/nginx-devel/2017-June/010087.html

the approach taken looks very fragile. There should be a better
way to do this.

--
Maxim Dounin
http://nginx.org/
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 01 of 14] Output chain: propagate last_buf flag to c->send_chain()

Piotr Sikora via nginx-devel 911 June 22, 2017 04:36PM

[PATCH 02 of 14] Upstream keepalive: preserve c->data

Piotr Sikora via nginx-devel 330 June 22, 2017 04:36PM

[PATCH 03 of 14] HTTP/2: add debug logging of control frames

Piotr Sikora via nginx-devel 403 June 22, 2017 04:36PM

Re: [PATCH 03 of 14] HTTP/2: add debug logging of control frames

Valentin V. Bartenev 446 July 03, 2017 10:00AM

Re: [PATCH 03 of 14] HTTP/2: add debug logging of control frames

Piotr Sikora via nginx-devel 413 July 05, 2017 06:04AM

Re: [PATCH 03 of 14] HTTP/2: add debug logging of control frames

Valentin V. Bartenev 523 July 10, 2017 11:28AM

[PATCH 04 of 14] HTTP/2: s/client/peer/

Piotr Sikora via nginx-devel 456 June 22, 2017 04:36PM

[PATCH 05 of 14] HTTP/2: introduce h2c->conf_ctx

Piotr Sikora via nginx-devel 413 June 22, 2017 04:36PM

[PATCH 06 of 14] HTTP/2: introduce stream->fake_connection

Piotr Sikora via nginx-devel 474 June 22, 2017 04:36PM

[PATCH 07 of 14] HTTP/2: introduce ngx_http_v2_handle_event()

Piotr Sikora via nginx-devel 418 June 22, 2017 04:36PM

[PATCH 08 of 14] HTTP/2: add HTTP/2 to upstreams

Piotr Sikora via nginx-devel 677 June 22, 2017 04:36PM

[PATCH 09 of 14] Proxy: add "proxy_ssl_alpn" directive

Piotr Sikora via nginx-devel 612 June 22, 2017 04:36PM

Re: [PATCH 09 of 14] Proxy: add "proxy_ssl_alpn" directive

Maxim Dounin 376 July 13, 2017 12:30PM

[PATCH 10 of 14] Proxy: always emit "Host" header first

Piotr Sikora via nginx-devel 342 June 22, 2017 04:36PM

Re: [PATCH 10 of 14] Proxy: always emit "Host" header first

Maxim Dounin 439 July 04, 2017 12:50PM

Re: [PATCH 10 of 14] Proxy: always emit "Host" header first

Piotr Sikora via nginx-devel 327 July 05, 2017 06:30AM

[PATCH 11 of 14] Proxy: split configured header names and values

Piotr Sikora via nginx-devel 416 June 22, 2017 04:36PM

Re: [PATCH 11 of 14] Proxy: split configured header names and values

Maxim Dounin 416 July 03, 2017 10:20AM

[PATCH 13 of 14] Proxy: add "proxy_pass_trailers" directive

Piotr Sikora via nginx-devel 485 June 22, 2017 04:36PM

[PATCH 12 of 14] Proxy: add HTTP/2 support

Piotr Sikora via nginx-devel 1301 June 22, 2017 04:36PM

Re: [PATCH 12 of 14] Proxy: add HTTP/2 support

Maxim Dounin 498 July 19, 2017 10:36AM

Re: [PATCH 12 of 14] Proxy: add HTTP/2 support

Piotr Sikora via nginx-devel 477 July 25, 2017 09:30PM

Re: [PATCH 12 of 14] Proxy: add HTTP/2 support

Piotr Sikora via nginx-devel 510 July 31, 2017 06:06PM

Re: [PATCH 12 of 14] Proxy: add HTTP/2 support

Maxim Dounin 587 August 08, 2017 02:06PM

[PATCH 14 of 14] Cache: add HTTP/2 support

Piotr Sikora via nginx-devel 475 June 22, 2017 04:36PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 134
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready