Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx "content_by_lua_block" directive is not allowed here #333

Open
nejinn opened this issue Dec 15, 2023 · 3 comments
Open

nginx "content_by_lua_block" directive is not allowed here #333

nejinn opened this issue Dec 15, 2023 · 3 comments

Comments

@nejinn
Copy link

nejinn commented Dec 15, 2023

nginx: [emerg] "content_by_lua_block" directive is not allowed here

stream {
    # define a TCP server listening on the port 1234:
    server {
        listen 1234;
        content_by_lua_block {
            ngx.say("Hello, Lua!")
        }
    }
}

nginx -v
nginx version: nginx/1.22.0

nginx -V
--prefix=/usr/local/nginx --with-pcre=../pcre-8.45 --with-zlib=../zlib-1.3 --with-openssl=../openssl-1.1.1q --pid-path=/data/logs/nginx/nginx.pid --error-log-path=/data/logs/nginx/error.log --http-log-path=/data/logs/nginx/access.log --lock-path=/var/run/nginx.lock --modules-path=/usr/local/nginx/modules --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --with-threads --with-http_sub_module --with-http_v2_module --with-http_auth_request_module --with-http_realip_module --with-http_secure_link_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_ssl_module --with-http_slice_module --with-http_stub_status_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-mail --with-mail_ssl_module --with-http_addition_module --with-http_random_index_module --with-compat --with-stream --with-file-aio --with-cc-opt='-Os -fomit-frame-pointer -g' --with-ld-opt=-Wl,-rpath,/usr/local/luajit/lib,--as-needed,-O1,--sort-common --add-module=/usr/local/src/ngx_devel_kit-0.3.1 --add-module=/usr/local/src/lua-nginx-module-0.10.21 --add-dynamic-module=/usr/local/src/echo-nginx-module-0.62 --add-dynamic-module=/usr/local/src/stream-lua-nginx-module-0.0.14rc1

when in http is ok

        location /lua {
            default_type 'text/plain';

            content_by_lua 'ngx.say("hello, lua")';
        }

@zhuizhuhaomeng
Copy link
Contributor

--add-dynamic-module=/usr/local/src/stream-lua-nginx-module-0.0.14rc1

have you loaded the stream-lua-nginx-module?

@nejinn
Copy link
Author

nejinn commented Dec 23, 2023

--add-dynamic-module=/usr/local/src/stream-lua-nginx-module-0.0.14rc1

have you loaded the stream-lua-nginx-module?

yes, stream-lua-nginx-module was in my nignx modules folder
/usr/local/nginx/modules/

@zhuizhuhaomeng
Copy link
Contributor

you need to load the module via load_module https://nginx.org/en/docs/ngx_core_module.html#load_module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants