Storing $server_addr in a variable VS using it directly in location block
Valentin V. Bartenev
vbart at nginx.com
Wed Jul 15 11:07:54 UTC 2015
On Tuesday 14 July 2015 21:46:58 justink101 wrote:
> According to the documentation getting the value of $server_addr to set a
> response header makes a system call, and can impact performance
> negativelyset $ip $server_addr;
>
> server {
> location /health {
> add_header Backend $server_addr;
> return 200;
> }
> }
>
> Would the following be a better solution, and eliminate the system call on
> every request?
>
> server {
> set $ip $server_addr;
>
> location /health {
> add_header Backend $ip always;
> return 200;
> }
> }
>
No, it wouldn't. The "set" directive also is executed on every request.
wbr, Valentin V. Bartenev
More information about the nginx
mailing list