请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

Nginx调用lua模块失败

老师,按照你的方法我安装了lua模块后检查了nginx配置语法出现nginx: [emerg] unknown directive “content_by_lua_file” in /usr/local/nginx/conf/nginx.conf:50这个报错

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }
	
	location /hello {
        default_type 'text/plain';
        content_by_lua_file 'ngx.say("hello, lua")';
    	}

	location /myip {
            default_type 'text/plain';
            content_by_lua '
            clientIP = ngx.req.get_headers()["x_forwarded_for"]
            ngx.say("IP:",clientIP)
            ';
    	}

	location / {
            default_type "text/html"; 
            content_by_lua_file /usr/local/nginx/conf/dep.lua;
            #add_after_body "$http_x_forwarded_for";
        }
        #
        location @server{
            proxy_pass http://127.0.0.1:9090;
        }
        
        location @server_test{
            proxy_pass http://127.0.0.1:8080;
        }

正在回答 回答被采纳积分+3

1回答

Jeson 2020-03-16 12:26:51

这个需要看下你的nginx_lua_module版本,如果在:

版本0.9.17以上,使用content_by_lua_block,lua-nginx-module 

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号