[PATCH] Make $proxy_host and $proxy_port accessible in dynamic languages

Maxim Dounin mdounin at mdounin.ru
Wed Oct 30 14:17:50 UTC 2013


Hello!

On Mon, Oct 28, 2013 at 02:44:45PM -0700, Yichun Zhang (agentzh) wrote:

> Hello!
> 
> On Mon, Oct 28, 2013 at 1:41 PM, Maxim Dounin wrote:
> >
> > What's the intended use?
> 
> I cannot really speak for my user. But one use case that I can think
> of is for (nonblocking) access logging in Lua, for example, as in
> 
>     https://github.com/cloudflare/lua-resty-logger-socket
> 
> where we can log $proxy_host and $proxy_port to a nonblocking socket in Lua :)

For logging, there is $upstream_addr variable, which is actually 
contatains some additional information, while $proxy_host is just 
a result of parsing the proxy_pass directive arguments.  The 
$proxy_host/$proxy_port variables are mostly for use in 
proxy_set_header Host, much like $proxy_add_x_forwarded_for.

Note well, that if there is a need to access these 
variables from dynamic languages for some reason, it can be easily 
done by adding a map{} into a configuration.

I tend to say "no", at least unless a better use case provided.  

-- 
Maxim Dounin
http://nginx.org/en/donation.html



More information about the nginx-devel mailing list