Как читать из postRequest в openresty?
Пытаюсь прочитать post request в openresty
# set search paths for pure Lua external libraries (';;' is the default path):
lua_package_path '/foo/bar/?.lua;/blah/?.lua;;';
# set search paths for Lua external libraries written in C (can also use ';;'):
lua_package_cpath '/bar/baz/?.so;/blah/blah/?.so;;';
server {
listen 8080;
server_name localhost;
location /api/ {
set_by_lua $proxy '
ngx.req.read_body()
local arg = ngx.req.get_uri_args()["venueId"] or 0
return arg
';
return 200 http://$proxy;
}
}
Получаю ошибку:
2021/08/19 12:30:38 [error] 8#8: *1 failed to run set_by_lua*: set_by_lua:2: API disabled in the context of set_by_lua*
stack traceback:
[C]: in function 'read_body'
set_by_lua:2: in main chunk, client: 172.17.0.1, server: localhost, request: "POST /api/qwe HTTP/1.1", host: "localhost:8080"
172.17.0.1 - - [19/Aug/2021:12:30:38 +0000] "POST /api/qwe HTTP/1.1" 500 183 "-" "PostmanRuntime/7.28.3"
Все библиотеки подключил использую докер:
# Using this base image because of: https://github.com/openresty/docker-openresty/issues/124
FROM openresty/openresty:1.15.8.1-4-centos
# Add the REDIS connection URL as an env variable in NGINX
RUN echo -e "env FLY_REDIS_CACHE_URL;\n$(cat /usr/local/openresty/nginx/conf/nginx.conf)" > /usr/local/openresty/nginx/conf/nginx.conf
# Add the configuration file
RUN rm /etc/nginx/conf.d/*
COPY o.conf /etc/nginx/conf.d/default.conf
Не понимаю, что не подключил чтобы нормально прочитал параметр из тела запроса?