文档章节

记Nginx之echo模块的坑:echo_exec之前不能有echo

anglix
 anglix
发布于 2015/12/30 01:52
字数 1149
阅读 508
收藏 8

关键配置

events {
 use epoll;
 multi_accept off;
 reuse_port on;
 worker_connections  1048576;
 debug_connection 127.0.0.1;
 debug_connection localhost;
}

error_log /var/log/nginx/error.log debug;

server {                                                                                                                                                                            
   listen       80 backlog=65535;
   server_name  lua.biliops.com;

   location / {
    set $name "higkoo";
    echo "name: $name"; # 有这行就出错,没有就正常。
    echo_exec /version;
   }

   location /version {
    content_by_lua '
        if jit then
            ngx.say(jit.version)
        else
            ngx.say(_VERSION)
        end
    ';
   }
}

错误信息

# curl -i lua.biliops.com
curl: (52) Empty reply from server

编译参数

# nginx -V
Tengine version: Tengine/2.1.1 (nginx/1.6.2)
built by gcc 4.9.2 (Debian 4.9.2-10) 
TLS SNI support enabled
configure arguments: --with-debug --user=www-data --group=www-data --with-pcre-jit \
--prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --dso-tool-path=/usr/sbin/dso_tool \
--dso-path=/usr/share/nginx/modules --conf-path=/etc/nginx/nginx.conf \
--http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log \
--lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid \
--http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
--http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi \
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-syslog --with-jemalloc --with-mail \
--with-http_lua_module --with-mail_ssl_module --with-http_ssl_module \
--with-http_auth_request_module --with-http_dav_module --with-http_gzip_static_module \
--with-http_image_filter_module --with-http_spdy_module --with-http_stub_status_module \
--with-http_realip_module --with-luajit-inc=/usr/include/luajit-2.0 \
--with-luajit-lib=/usr/lib/x86_64-linux-gnu --with-ld-opt=-Wl,-z,relro \
--with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' \
--add-module=../echo-nginx-module-0.58 --add-module=../ngx_cache_path_status-1.0 \
--add-module=../redis2-nginx-module-0.12 --add-module=../headers-more-nginx-module-0.261 \
--add-module=../ngx-fancyindex-0.3.5 --add-module=../memc-nginx-module-0.16 \
--add-module=../nginx-rtmp-module-1.1.7 --add-module=../ngx_slowfs_cache_p2p-1.10 \
--add-module=../ngx_devel_kit-0.2.19

调试日志

[debug] 2233#0: accept on 0.0.0.0:80, ready: 0
[debug] 2233#0: posix_memalign: 00007FED1284C300:256 @16
[debug] 2233#0: *3 accept: 192.168.9.199 fd:4
[debug] 2233#0: event dummy accept filter
[debug] 2233#0: posix_memalign: 00007FED1284C400:256 @16
[debug] 2233#0: *3 event timer add: 4: 60000:1451411133579
[debug] 2233#0: *3 reusable connection: 1
[debug] 2233#0: *3 epoll add event: fd:4 op:1 ev:80002001
[debug] 2233#0: *3 http wait request handler
[debug] 2233#0: *3 malloc: 00007FED12839C00:1024
[debug] 2233#0: *3 recv: fd:4 79 of 1024
[debug] 2233#0: *3 reusable connection: 0
[debug] 2233#0: *3 posix_memalign: 00007FED128DC000:4096 @16
[debug] 2233#0: *3 http process request line
[debug] 2233#0: *3 http request line: "GET / HTTP/1.1"
[debug] 2233#0: *3 http uri: "/"
[debug] 2233#0: *3 http args: ""
[debug] 2233#0: *3 http exten: ""
[debug] 2233#0: *3 http process request header line
[debug] 2233#0: *3 http header: "User-Agent: curl/7.38.0"
[debug] 2233#0: *3 http header: "Host: lua.biliops.com"
[debug] 2233#0: *3 posix_memalign: 00007FED1292D000:4096 @16
[debug] 2233#0: *3 http header: "Accept: */*"
[debug] 2233#0: *3 http header done
[debug] 2233#0: *3 event timer del: 4: 1451411133579
[debug] 2233#0: *3 generic phase: 0
[debug] 2233#0: *3 rewrite phase: 1
[debug] 2233#0: *3 test location: "/"
[debug] 2233#0: *3 using configuration "/"
[debug] 2233#0: *3 http cl:-1 max:67108864
[debug] 2233#0: *3 rewrite phase: 3
[debug] 2233#0: *3 http script value: "higkoo"
[debug] 2233#0: *3 http script set $name
[debug] 2233#0: *3 post rewrite phase: 4
[debug] 2233#0: *3 generic phase: 5
[debug] 2233#0: *3 generic phase: 6
[debug] 2233#0: *3 generic phase: 7
[debug] 2233#0: *3 generic phase: 8
[debug] 2233#0: *3 access phase: 9
[debug] 2233#0: *3 access phase: 10
[debug] 2233#0: *3 access phase: 11
[debug] 2233#0: *3 post access phase: 12
[debug] 2233#0: *3 http script copy: "name: "
[debug] 2233#0: *3 http script var: "higkoo"
[debug] 2233#0: *3 lua capture header filter, uri "/"
[debug] 2233#0: *3 HTTP/1.1 200 OK
Server: Tengine
Date: Tue, 29 Dec 2015 23:33:33 GMT
Content-Type: text/plain
Transfer-Encoding: chunked
Connection: keep-alive
[debug] 2233#0: *3 write new buf t:1 f:0 00007FED1292D378, pos 00007FED1292D378, size: 151 file: 0, size: 0
[debug] 2233#0: *3 http write filter: l:0 f:0 s:151
[debug] 2233#0: *3 http output filter "/?"
[debug] 2233#0: *3 http copy filter: "/?"
[debug] 2233#0: *3 lua capture body filter, uri "/"
[debug] 2233#0: *3 http trim filter
[debug] 2233#0: *3 http footer body filter
[debug] 2233#0: *3 image filter
[debug] 2233#0: *3 http postpone filter "/?" 00007FED1292D488
[debug] 2233#0: *3 http chunk: 12
[debug] 2233#0: *3 http chunk: 1
[debug] 2233#0: *3 write old buf t:1 f:0 00007FED1292D378, pos 00007FED1292D378, size: 151 file: 0, size: 0
[debug] 2233#0: *3 write new buf t:1 f:0 00007FED1292D528, pos 00007FED1292D528, size: 3 file: 0, size: 0
[debug] 2233#0: *3 write new buf t:0 f:0 00007FED1292D248, pos 00007FED1292D248, size: 12 file: 0, size: 0
[debug] 2233#0: *3 write new buf t:0 f:0 00000000007B06A8, pos 00000000007B06A8, size: 1 file: 0, size: 0
[debug] 2233#0: *3 write new buf t:0 f:0 0000000000000000, pos 000000000054A17D, size: 2 file: 0, size: 0
[debug] 2233#0: *3 http write filter: l:0 f:0 s:169
[debug] 2233#0: *3 http copy filter: 0 "/?"
[debug] 2233#0: *3 internal redirect: "/version?"
[debug] 2233#0: *3 rewrite phase: 1
[debug] 2233#0: *3 test location: "/"
[debug] 2233#0: *3 test location: "version"
[debug] 2233#0: *3 using configuration "/version"
[debug] 2233#0: *3 http cl:-1 max:67108864
[debug] 2233#0: *3 rewrite phase: 3
[debug] 2233#0: *3 post rewrite phase: 4
[debug] 2233#0: *3 generic phase: 5
[debug] 2233#0: *3 generic phase: 6
[debug] 2233#0: *3 generic phase: 7
[debug] 2233#0: *3 generic phase: 8
[debug] 2233#0: *3 access phase: 9
[debug] 2233#0: *3 access phase: 10
[debug] 2233#0: *3 access phase: 11
[debug] 2233#0: *3 post access phase: 12
[debug] 2233#0: *3 lua content handler, uri:"/version" c:2
[debug] 2233#0: *3 lua reset ctx
[debug] 2233#0: *3 lua creating new thread
[debug] 2233#0: *3 http cleanup add: 00007FED1292D7E0
[debug] 2233#0: *3 lua run thread, top:0 c:2
[debug] 2233#0: *3 lua allocate new chainlink and new buf of size 13, cl:00007FED1292D7F8
[debug] 2233#0: *3 lua say response
[debug] 2233#0: *3 http output filter "/version?"
[debug] 2233#0: *3 http copy filter: "/version?"
[debug] 2233#0: *3 lua capture body filter, uri "/version"
[debug] 2233#0: *3 http trim filter
[debug] 2233#0: *3 http footer body filter
[debug] 2233#0: *3 image filter
[debug] 2233#0: *3 http postpone filter "/version?" 00007FED1292D7F8
[debug] 2233#0: *3 http chunk: 13
[alert] 2333#0: worker process 2233 exited on signal 11
[debug] 3333#0: epoll add event: fd:4 op:1 ev:00002001

© 著作权归作者所有

anglix

anglix

粉丝 32
博文 35
码字总数 17615
作品 0
珠海
系统管理员
私信 提问
lua配合nginx进行代码(nginx配置文件)调试

nginx有echo模块可以实现输出字符串到web浏览器上,实现方式如下: 首先要nginx支持echo模块,然后在修改配置文件进行测试。 下载模块: 下载路径:https://github.com/openresty/echo-nginx...

xinsir999
2017/10/05
0
0
PHP 对外提供API

linux nginx php 架构 环境搭建参考: http://my.oschina.net/u/1445488/blog/632611 以下为PHP代码demo. <?php //echo phpinfo(); $url=urldecode($SERVER['REQUESTURI']); //echo $url; $......

悬崖
2016/03/09
47
0
C语言开发的原生 Nginx 拓展--nginx-http-echo-module

nginx-http-echo-module 是使用C语言开发一个原生的Nginx拓展,为了学习Nginx模块和Nginx内核。 nginxmoduleecho 使用echo指令输出一个字符串 Nginx 版本 Nginx1.0.10 https://github.com/ngi...

卧龙大熊猫
2017/06/14
142
0
panda/nginx_module_echo

实战开发一个Nginx扩展 (Nginx Module) nginxmoduleecho 使用echo指令输出一个字符串 Nginx 版本 Nginx1.0.10 https://github.com/nginx/nginx/releases/tag/release-1.0.10 开发环境 OS : C......

panda
2017/06/13
0
0
CentOS 7.4 Tengine安装配置详解(三)

九、根据HTTP响应状态码自定义错误页: 1、未配置前访问一个不存在的页面:http://192.168.1.222/abc/def.html,按F12后刷新页面 2、在server{}配置段中新增如下location: server { listen ...

Marion0728
2018/06/26
0
0

没有更多内容

加载失败,请刷新页面

加载更多

多个数组排列问题

有时候会有需求 从N个数组个各取1个元素组成新数组,问有多少种可能,分别是什么?(这里假设不涉及重复元素和顺序影响) 类似 [a,b,c,d],[1,2],[A,B,F] 3个数组个各取一个元素组成新数组,共计...

chro008
20分钟前
1
0
mongodb中的_id的ObjectId的生成规则

https://www.cnblogs.com/weilunhui/p/6861938.html

Java搬砖工程师
24分钟前
2
0
ngx限流模块

服务器流量异常,负载过大 ngx_http_limit_conn_module模块实现对同一个 ip 的连接数,并发数进行限制。 语法: limit_conn_zone $variable zone=name:size; 描述会话状态存储区域。键的状态中...

SibylY
28分钟前
3
0
大型网站架构系列:电商网站架构案例(3)

大型网站架构系列:电商网站架构案例(3) 本文章是电商网站架构案例的第三篇,主要介绍数据库集群,读写分离,分库分表,服务化,消息队列的使用,以及本电商案例的架构总结。 6.5数据库集群(...

linzhuangrong
31分钟前
2
0
技术文章收集

1. Java Web 程序员,我们一起给程序开个后门吧:让你在保留现场,服务不重启的情况下,执行我们的调试代码 gitHub

近在咫尺远在天涯
36分钟前
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部