这里不允许使用NGINX-"set"指令

use*_*868 5 variables configuration nginx

我试图在这里遵循这个例子 - https://gist.github.com/morhekil/1ff0e902ed4de2adcb7a#file-nginx-conf但是得到错误 - "set" directive is not allowed here

我究竟做错了什么?请注意,我使用openresty并调用nginx作为 -

nginx -p `pwd`/ -c conf/nginx.conf 
Run Code Online (Sandbox Code Playgroud)

我的nginx.conf的上下文完全匹配https://gist.github.com/morhekil/1ff0e902ed4de2adcb7a#file-nginx-conf

如果我将set变量移动到服务器部分,我不再得到该错误但是新的错误 -

nginx: [emerg] unknown "resp_body" variable
Run Code Online (Sandbox Code Playgroud)

efk*_*kan 16

几个月后,答案即将来临:)

Github配置文件似乎有误.set指令用于在server,locationif块.

语法:set $ variable value;
默认值: -
上下文: 服务器,位置,如果

http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#set

祝好运!