Variable interpolation inside Map directive

I am trying to map a variable inside the http directive in Nginx.

When you are alone, only one variable expands; if I add anything else to the string, the extension stops working.

http {

    map $host $foo {
        #default "$host";                    # - this works fine and returns 'localhost' 
        default "This is my host: $host";    # - THIS DOESN'T WORK
    }

    server {

        location / {
            echo $foo;
        }

    }

}

Do you have any suggestions for expanding the work inside the map?

+4
source share
1 answer

As stated in the directive map documentation :

The resulting value may be a string or another variable (0.9.0).

Update: . This functionality was added to NGinx version 1.11.2 in accordance with comment No. 7 here: https://trac.nginx.org/nginx/ticket/663#comment:7

+2
source

All Articles