Variables Nginx-变量用法(set vs map)上下文和用法
在Nginx配置中 我不知道何时/何地可以使用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
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和“变量”有没有办法做到这一点