Maxim Dounin mdounin at
Fri Oct 22 01:40:33 UTC 2021


On Thu, Oct 21, 2021 at 12:20:21PM -0400, Benjamin Coddington wrote:

> Hi devs,  I'm new here, be gentle.
> I'm hacking up a tls offloading proxy for sunrpc, getting up to speed on
> nginx codebase, but I'm sinking too much time into figuring something:
> I'd like to use a flag configuration directive within an upstream config
> stanza:
> static ngx_command_t
> ngx_stream_rpc_tls_commands[] = {
>     { ngx_string("rpc_tls_client"),
>       ngx_conf_set_flag_slot,
>       offsetof(ngx_stream_rpc_tls_conf_t, client),
>       NULL },
>     ngx_null_command
> };
> .. but when I go to merge server configs, the value is always unset.  The
> debugger showed me that the upstream module does its own pass at
> module->create_srv_conf
> and
> ngx_conf_parse()
> so the configuration, while set, isn't there in my merge server config
> function, it's somewhere else and I'm not sure how to access it.
> I'm at the point where it feels like I'm "doing it wrong".  What's the
> correct way to have both NGX_STREAM_SRV_CONF|NGX_CONF_FLAG and
> module that can be handled by the same module's configuration?

The upstream{} block is a separate entity which isn't subject for 
configuration merging.  Any initialization is expected to be 
handled in the uscf->peer.init_upstream handler, as set by 
balancers and called by the ngx_stream_upstream_init_main_conf().

For examples on how to use it, check various balancers code.  In 
particular, ngx_http_upstream_keepalive_module might be 
interesting, as it provides several configuration directives.

Maxim Dounin

More information about the nginx-devel mailing list