pls. help for adding another parameter to ngx_upstream_server

moto kawasaki moto at
Fri Nov 15 08:35:39 UTC 2013

Dear Sirs,

Firstly, I'd like to thank you very much for supplying such powerful
and smart software. nginx is so great.

Now, I am struggling to add "setfib=N" parameter to "server" token in
"upstream" clause, and so far failed.

It is really appreciated if you'd advice/suggest/comment on it.
Thank you very very much in advance.

[my environment]
  - FreeBSD 9.2-RELEASE-p0
  - www/nginx (ports), which is nginx-1.4.3.

[my intention]
  - nginx can listen with setfib.

  - but nginx cannot setfib against upstream/server.

  - I'd like to add "setfib" parameter, something like below;

      upstream backend {
          server max_fails=3 setfib=5;     # (a)
      } #                                     ^^^^^^^^

[what I did]
  - I made a patch (see attached) but it fails with the following
    emerge message in nginx-error.log.

      [emerg] 3848#0: invalid parameter "setfib=5" in /usr/local/etc/nginx/nginx.conf:18
    The line 18 of nginx.conf contains setfib=5 (see (a) above.)

  - printf debugging tells me;

    (1) This emerg log comes from "invalid" clause in function
        ngx_http_upstream_server() at line 4689 of
	ngx_http_upstream.c. (line numbers are AFTER applying attached

          4689 invalid:
          4691     ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
          4692                        "invalid parameter \"%V\"", &value[i]);

        And it is because "uscf->flags" check failed at l.4649.

          4649             if (!(uscf->flags & NGX_HTTP_UPSTREAM_SETFIB)) {
          4650                 goto invalid;
          4651             }

    (2) This "uscf->flags" has been set in the function
        ngx_http_upstream() at line 4434;

          4434     uscf = ngx_http_upstream_add(cf, &u, NGX_HTTP_UPSTREAM_CREATE
          4435                                          |NGX_HTTP_UPSTREAM_WEIGHT
          4436                                          |NGX_HTTP_UPSTREAM_MAX_FAILS
	  4437                                          |NGX_HTTP_UPSTREAM_FAIL_TIMEOUT
	  4438                                          |NGX_HTTP_UPSTREAM_DOWN
	  4439 #if (NGX_HAVE_SETFIB)
	  4440                                          |NGX_HTTP_UPSTREAM_BACKUP
	  4441                                          |NGX_HTTP_UPSTREAM_SETFIB);
	  4442 #else
	  4443                                          |NGX_HTTP_UPSTREAM_BACKUP);
	  4444 #endif /* NGX_HAVE_SETFIB */

        And keep the bit of NGX_HTTP_UPSTREAM_SETFIB as ON, so that the
	uscf->flags=127, until just before the function
	ngx_conf_parse() called.

          4511     rv = ngx_conf_parse(cf, NULL);

        Returning from this function, uscf->flags=31, which means the
	SETFIB bit is OFF, thus check at l.4649 falls into invalid.

[my questions]

Well, I tried but couldn't find out where that bit being set OFF.
So, please tell me the place or how to preserve it.

Also, please advice me whether my logic above is wrong or not, where I
made a mistake, how to achieve setfib option in upstream/server, etc.

Thank you very much.

Best Regards,

moto kawasaki <moto at>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: nginx-upstreamsetfib.patch
Type: text/x-patch
Size: 4186 bytes
Desc: not available
URL: <>

More information about the nginx-devel mailing list