Welcome! Log In Create A New Profile

Advanced

Re: upstream_response_length and upstream_addr can't work

Roman Arutyunyan
November 26, 2019 08:12AM
Hi,

On Tue, Nov 26, 2019 at 07:24:00PM +0800, lx wrote:
> hi all:
> When I use module of slice, upstream_response_length and
> upstream_addr can't work.
> nginx.conf :
> #########################################################################
> include mime.types;
> default_type application/octet-stream;
>
> log_format main
> '$status^$scheme^$request^$body_bytes_sent^$request_time^$upstream_cache_status^$remote_addr^$http_referer^$http_user_agent^$content_type^$http_range^$cookie_name^$upstream_addr^$upstream_response_time^$upstream_bytes_received^$upstream_response_length^[$time_local]';
>
>
> access_log logs/access.log main;
> rewrite_log on;
>
> sendfile on;
> aio threads;
>
> keepalive_timeout 65;
>
> if ($uri ~ ^/([a-zA-Z0-9\.]+)/([a-zA-Z0-9\.]+)/(.*)) {
> set $cdn $1;
> set $new_host $2;
> set $new_uri $3;
> }
>
> location / {
> slice 1m;
> proxy_cache_lock on;
> proxy_cache my_cache;
> proxy_cache_key $uri$is_args$args$slice_range;
> proxy_set_header Range $slice_range;
> proxy_cache_valid 200 206 24h;
> proxy_pass http://$cdn/$new_uri;
> }
> #########################################################################
> I Initiate a rang htttp request, for example
> #########################################################################
> curl -o result -H 'Range: bytes=2001-4932000' "
> http://127.0.0.1:64002/A.com/B.com/appstore/developer/soft/20191008/201910081449521157660.patch
> "
> #########################################################################
> upstream_response_length and upstream_bytes_received is just 1 MB, not
> 4.9MB. I find nginx build 5 http request to A.com by tcpdump, and nginx
> implement slice by subrequest.
>
> This is why? How to fix it?

Yes. When using the slice module, response is served by multiple subrequests.
Each subrequest serves its own part. It has a separate cache key, fetches a
separate cache entry and contacts the upstream server using a serparate
connection. When you use an $upstream_XXX variable, it returns data from
a subrequest.

If you want combined numbers, use client-side variables like $bytes_sent
instead.

>
> Thank you

> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx


--
Roman Arutyunyan
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

upstream_response_length and upstream_addr can't work

lx November 26, 2019 06:26AM

Re: upstream_response_length and upstream_addr can't work

Roman Arutyunyan November 26, 2019 08:12AM

Re: upstream_response_length and upstream_addr can't work

lx November 26, 2019 08:16PM

Re: upstream_response_length and upstream_addr can't work

Roman Arutyunyan November 27, 2019 05:22AM

Re: upstream_response_length and upstream_addr can't work

lx November 28, 2019 05:42AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 247
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 466 on July 09, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready