Storing $server_addr in a variable VS using it directly in location block

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;
    }
}

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,260304,260304#msg-260304

On Tuesday 14 July 2015 21:46:58 justink101 wrote:

}

No, it wouldn’t. The “set” directive also is executed on every request.

wbr, Valentin V. Bartenev

Valentin V. Bartenev Wrote:

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;

No, it wouldn’t. The “set” directive also is executed on every
request.

Via map as well ? (geo would suffer as well then)

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,260304,260320#msg-260320

On Wednesday 15 July 2015 07:45:34 itpp2012 wrote:

Via map as well ? (geo would suffer as well then)

All variables work on a per requests basis, no exceptions.

wbr, Valentin V. Bartenev

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs