Welcome! Log In Create A New Profile

Advanced

Using $upstream_response_time in add_header shows a dash

February 05, 2021 03:38PM
Hello all,

I have this example nginx.conf: https://gist.github.com/MarioIshac/e6971ab0b343da210de62ebb1c6e2f99 to reproduce the behavior.

I start nginx and an example upstream with:

python3 -u -m http.server 8001 > app.log 2>&1 & sudo nginx > nginx.log 2>&1

Upon hitting nginx with `curl -i localhost:8000`, I see these response headers:

X-Trip-Time: 0.001
X-Addr: 127.0.0.1:8001
X-Status: 200
X-Process-Time: -

`cat app.log` shows that upstream was hit successfully, and `cat nginx.log` shows that nginx knows the $upstream_response_time at log time, as I get this log:

127.0.0.1:8001 200 0.004

Why does nginx substitute the request time and relevant response metadata (like $upstream_status) at add_header time successfully, yet substitutes the upstream response time with a dash?

My goal with returning $upstream_response_time in a header is so the client can know how much of their request latency was due to their upload speeds vs. server processing time.

-Mario
Subject Author Posted

Using $upstream_response_time in add_header shows a dash

MarioIshac February 05, 2021 03:38PM

Re: Using $upstream_response_time in add_header shows a dash

Maxim Dounin February 07, 2021 11:00AM

Re: Using $upstream_response_time in add_header shows a dash

MarioIshac February 07, 2021 05:51PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 204
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