我在Nginx上有一个安全和X-Accel-Redirect的问题。
location /api {
allow 100.100.100.1;
deny all;
proxy_pass http://api-server;
}
#The api-sever will respond with an `X-Accel-Redirect` header to the following location `@server888`
location @server888 {
internal;
proxy_pass http://server888$request_uri;
}Nginx 888对/api具有相同的配置
location /api {
allow 100.100.100.1;
deny all;
proxy_pass http://api-server;
}但是,从源ip 100.100.100.1到Server 777的所有请求都从服务器777获得403个响应,错误如下:
access forbidden by rule while reading response header from upstream据我所见,@server888位置阻塞了请求,但我的理解是,internal指令应该允许来自X-Accel-Redirect的请求,而不必为100.100.100.1提供显式的allow指令。
这是正确的吗?还是需要在@server888位置授予更广泛的权限才能工作?
发布于 2019-11-13 14:25:58
因此,自定义location (@server888)需要允许环回地址才能工作:
location @server888 {
allow 127.0.0.1;
internal;
proxy_pass http://server888$request_uri;
}我不知道这是什么技术解释。
通常,当请求由internal生成时,X-Accel-Redirect指令应该允许访问:
http://nginx.org/en/docs/http/ngx_http_核心_module.html#internal
我在这里的猜测是,这只适用于location是本地的,而不是上游的反向代理,或者这个位置继承了配置中更早的全局deny all;。
https://serverfault.com/questions/991513
复制相似问题