Openresty中的proxy_pass

时间:2019-07-15 11:23:30

标签: nginx proxy openresty

我想在Lua中检查某些内容,然后使用Nginx代码在目标中使用proxy_pass,但不起作用!

location /nt {
    default_type 'text/plain';
    content_by_lua_block{
        local res = ngx.location.capture("/download_server")
        if res.status == ngx.HTTP_OK then
          proxy_buffering off;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header Host $http_host;
          proxy_http_version 1.1;
          limit_req_status 444;
          proxy_pass http://127.0.0.1:3000;
        else
          ngx.say('Failed to process, please try again in some minutes.')
        end
    }
}


location /download_server {
    proxy_pass http://127.0.0.1:3000/nt;
}

1 个答案:

答案 0 :(得分:0)

您混合使用Lua代码和nginx指令。显然不起作用。在content_by_lua_block中,只能是Lua代码