Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables Nginx-变量用法(set vs map)上下文和用法_Variables_Nginx_Nginx Location - Fatal编程技术网

Variables Nginx-变量用法(set vs map)上下文和用法

Variables Nginx-变量用法(set vs map)上下文和用法,variables,nginx,nginx-location,Variables,Nginx,Nginx Location,在Nginx配置中 我不知道何时/何地可以使用map或set 我想这样做: 我尝试使用map: map $host $proxy_destination_include { default '/etc/nginx/conf.d/params/proxy.params/proxy_params_destination.conf'; } 或尝试使用set: server { ### I want to use this as either a variabl

在Nginx配置中

我不知道何时/何地可以使用
map
set

我想这样做:

我尝试使用
map

    map $host $proxy_destination_include {
        default '/etc/nginx/conf.d/params/proxy.params/proxy_params_destination.conf';
    }
或尝试使用
set

server {
    ### I want to use this as either a variable / map ###
    set $proxy_destination_include /etc/nginx/conf.d/params/proxy.params/proxy_params_destination.conf;

    root /var/www/html;

    location / {
         set_proxy_header X-Forwarded-Location-Site 'static-value';
         include $proxy_destination_include;
    }

    location /otherlocation {
         set_proxy_header X-Forwarded-Location-Site 'static-value-2';
         include $proxy_destination_include;
    }
}
但我认为
map
只能在“站点请求”完成时使用?因此,由于尚未映射,Nginx无法成功编译其设置-
sudo Nginx-t
失败

  • 使用Nginx和“变量”有没有办法做到这一点