Hello,
A quick question:
Does nginx have a variable which will give me the actual upstream
server:port for the selected upstream server ?
For instance, if I have:
upstream xxx
{
server s1:7070;
server s2:7070;
server s3:7070;
server s4:7070;
}
and if I have
server
{
...
location /
{
proxy_pass http://xxx;
proxy_set_header Host $variable_name; # <-- which variable
should I use here, to get “s1:7070” or “s2:7070”, etc. ?
}
…
}
$server_name gives me the FQDN of the proxy server,
$proxy_host gives me the name of the upstream block (in this case,
“xxx”)
Which variable should I use in order to get the precise name of the
selected upstream server ?
Thanks
Mansoor P.
Not sure if this is available at the stage in the request that you
want it, but you could try:
$upstream_addr – address of the upstream server that handled the
request
via: http://wiki.codemongers.com/NginxHttpUpstreamModule
On Tue, Feb 26, 2008 at 04:22:03AM -0800, Mansoor P. wrote:
server s4:7070;
proxy_set_header Host $variable_name; # <-- which variable should I use here, to get "s1:7070" or "s2:7070", etc. ?
}
...
}
$server_name gives me the FQDN of the proxy server,
$proxy_host gives me the name of the upstream block (in this case, “xxx”)
Which variable should I use in order to get the precise name of the selected upstream server ?
No, there is no such variable: it’s expected that upstreams are equal.
On Tue, Feb 26, 2008 at 11:06:28AM -0800, Eden Li wrote:
Not sure if this is available at the stage in the request that you
want it, but you could try:
$upstream_addr – address of the upstream server that handled the
request
No, first, $upstream_addr is not read at this stage, and second,
it’s in unsuitable format: “192.168.1.1:80, 192.168.1.2:80”.