NGINX配置-验证请求主体不工作

NGINX配置-验证请求主体不工作,nginx,nginx-reverse-proxy,nginx-config,Nginx,Nginx Reverse Proxy,Nginx Config,我遵循验证请求主体下的步骤 输入请求json验证后重新启动nginx时出现以下异常 bind() to 127.0.0.1:10415 failed (13: Permission denied) 我已经使用下面的命令在同一台服务器中打开了同一个端口 firewall-cmd --zone=public --add-port=10415/tcp --permanent 下面一行是阻止启动:api_gateway.conf js_include json_validator.js; js_se

我遵循验证请求主体下的步骤

输入请求json验证后重新启动nginx时出现以下异常

bind() to 127.0.0.1:10415 failed (13: Permission denied)
我已经使用下面的命令在同一台服务器中打开了同一个端口

firewall-cmd --zone=public --add-port=10415/tcp --permanent
下面一行是阻止启动:api_gateway.conf

js_include json_validator.js;
js_set $validated json_validator;
server {
    listen 127.0.0.1:10415; # This is the error response of json_validator()
    return 415; # Unsupported media type
    include api_json_errors.conf;
}
为什么会这样?请帮忙

添加我的完整配置: json\u-validated.js

function json_validator(req) {
    try {
        req.log('JSON.parse exception before');
        if ( req.variables.request_body.length > 0 ) {
            req.log('JSON.parse exception inside if');
            JSON.parse(req.variables.request_body);
            req.log('JSON.parse exception inside if after parse');
        }
        req.log('JSON.parse exception inside if before return');
        req.log(req.variables.upstream);
        return req.variables.upstream;
    } catch (e) {
        req.log('JSON.parse exception');
        return '127.0.0.1:10415'; // Address for error response
    }
}
api_test.conf

location = /_external {
    internal;
    proxy_pass https://$validated$request_uri;
}
  location = /_external {
        internal;
   if ($validated = "") {
        return 415; 
    }
        proxy_pass https://$validated$request_uri;
    }
还尝试像这样使用$validated,以便根据下面的条件返回错误,但这似乎不起作用, 尝试 api_test.conf

location = /_external {
    internal;
    proxy_pass https://$validated$request_uri;
}
  location = /_external {
        internal;
   if ($validated = "") {
        return 415; 
    }
        proxy_pass https://$validated$request_uri;
    }
当时我看到下面的日志总是关于正确或不正确的json输入

2020/02/14 01:59:33 [info] 20275#20275: *2 js: JSON.parse exception before
2020/02/14 01:59:33 [info] 20275#20275: *2 js: JSON.parse exception

您是否启用了SELinux?是的。”[root@mine]#sestatus SELinux状态:已启用SELinux装载:/sys/fs/SELinux SELinux根目录:/etc/SELinux加载的策略名称:目标当前模式:从配置文件强制执行模式:强制执行策略MLS状态:已启用策略拒绝\u未知状态:允许Max kernel policy version:31“您能暂时禁用它并重新启动nginx吗
SetEnforce0
尝试了rootyes。现在我遇到以下异常,它尝试连接到此api地址,但不抛出415;#不支持的媒体类型错误。错误:读取客户端请求行(客户端:127.0.0.1)时失败(104:由对等方重置连接),上游URI为:“”在原始问题中添加了更多配置设置@伊凡沙茨基