: invalid parameter "backup" error on Ubuntu

Greetings:

I am running 0.8.14 on Ubuntu (compiled from source with openssl).

Desired result is static cache as backup for dynamic asp webapp. Cache
builds nicely, serves fine on 127.0.0.2:80 or unix socket, however when
I attempt to manage weights and also specify that 127.0.0.2:80 is backup
I get:

: invalid parameter “backup”

This works fine -

upstream backend {
ip_hash;
server web2-1.example.com;
server web2-2.example.com down;
server web2-3.example.com;
server web2-4.example.com;
server 127.0.0.2:80;
}

but I cannot add “weight”, “max_fails” or “backup”. Am I missing a
module? Note that I am unable to compile in nginx_upstream_hash-0.3 so
far.

Stefan C.

Posted at Nginx Forum:

Hello!

On Tue, Sep 08, 2009 at 09:18:25AM -0400, stefancaunter wrote:

upstream backend {
ip_hash;
server web2-1.example.com;
server web2-2.example.com down;
server web2-3.example.com;
server web2-4.example.com;
server 127.0.0.2:80;
}

but I cannot add “weight”, “max_fails” or “backup”. Am I missing a module? Note that I am unable to compile in nginx_upstream_hash-0.3 so far.

Ip_hash balancer does not support backup servers and weight,
though max_fails should work.

For weighting you may just specify the same server multiple times,
instead of backup you may use error_page-based fallback.

Maxim D.

this is the funny thing, with ip_hash removed from upstream config, I
still get

: invalid parameter “backup”

and I’m not sure why. I wonder if anyone sees this behaviour. I can flip
to the backup server but it isn’t automatic…

Posted at Nginx Forum:

By hostname do you mean “http://backend” (upstream name) ?

proxy_pass http://backend;

If upstream is outside of location container it is allowed, but it still
doesn’t recognize “backup”.

Posted at Nginx Forum:

Hello!

On Tue, Sep 08, 2009 at 11:05:04AM -0400, stefancaunter wrote:

this is the funny thing, with ip_hash removed from upstream config, I still get

: invalid parameter “backup”

and I’m not sure why. I wonder if anyone sees this behaviour. I can flip to the backup server but it isn’t automatic…

This usually means that you used upstream before definition and
therefore default upstream was implicitly created (assuming you
just used hostname in proxy_pass).

Maxim D.

Hello!

On Tue, Sep 08, 2009 at 11:49:07AM -0400, stefancaunter wrote:

By hostname do you mean “http://backend” (upstream name) ?

proxy_pass http://backend;

Directive proxy_pass accepts either upstream name as defined
earlier via upstream{} block or backend hostname (or ip, or unix
socket). In the later case it implicitly creates upstream
block with single server inside.

Therefore this will work as expected:

http {
upstream backend {
server 192.168.0.1:80;
server 192.168.0.2:80 backup;
}

server {
    ...
    location / {
        proxy_pass http://backend;
    }
}

}

And this will fail claiming it can’t use “backup”, as nginx will
interpret “backend” string as hostname that should be resolved via
DNS and will be confused by “upstream backend { … }” that comes
later on:

http {
server {

location / {
proxy_pass http://backend;
}
}

upstream backend {
    server 192.168.0.1:80;
    server 192.168.0.2:80 backup;
}

}

Maxim D.