Set a default variable in nginx with set

Solution 1:

map $foo $new_foo {
    default  $foo;
    ''       bar;
}

or

if ($foo = '') {
    set $foo bar;
}
  • http://nginx.org/r/map
  • http://nginx.org/r/if