Nginx 的 Echo 模块 —— echo-nginx-module(转)
Nginx 有个 echo 模块可以用来输出一些简单的信息,例如:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
location /hello { echo "hello, world!" ; } location /hello { echo -n "hello, " echo "world!" ; } location /timed_hello { echo_reset_timer; echo hello world; echo "'hello world' takes about $echo_timer_elapsed sec." ; echo hiya igor; echo "'hiya igor' takes about $echo_timer_elapsed sec." ; } location /echo_with_sleep { echo hello; echo_flush; # ensure the client can see previous output immediately echo_sleep 2.5; # in sec echo world; } # in the following example, accessing /echo yields # hello # world # blah # hiya # igor location /echo { echo_before_body hello; echo_before_body world; proxy_pass $scheme: //127 .0.0.1:$server_port$request_uri /more ; echo_after_body hiya; echo_after_body igor; } location /echo/more { echo blah; } # the output of /main might be # hello # world # took 0.000 sec for total. # and the whole request would take about 2 sec to complete. location /main { echo_reset_timer; # subrequests in parallel echo_location_async /sub1 ; echo_location_async /sub2 ; echo "took $echo_timer_elapsed sec for total." ; } location /sub1 { echo_sleep 2; echo hello; } location /sub2 { echo_sleep 1; echo world; } # the output of /main might be # hello # world # took 3.003 sec for total. # and the whole request would take about 3 sec to complete. location /main { echo_reset_timer; # subrequests in series (chained by CPS) echo_location /sub1 ; echo_location /sub2 ; echo "took $echo_timer_elapsed sec for total." ; } location /sub1 { echo_sleep 2; echo hello; } location /sub2 { echo_sleep 1; echo world; } # Accessing /dup gives # ------ END ------ location /dup { echo_duplicate 3 "--" ; echo_duplicate 1 " END " ; echo_duplicate 3 "--" ; echo ; } # /bighello will generate 1000,000,000 hello's. location /bighello { echo_duplicate 1000_000_000 'hello' ; } # echo back the client request location /echoback { echo_duplicate 1 $echo_client_request_headers; echo "\r" ; echo_read_request_body; echo_request_body; } # GET /multi will yields # querystring: foo=Foo # method: POST # body: hi # content length: 2 # /// # querystring: bar=Bar # method: PUT # body: hello # content length: 5 # /// location /multi { echo_subrequest_async POST '/sub' -q 'foo=Foo' -b 'hi' ; echo_subrequest_async PUT '/sub' -q 'bar=Bar' -b 'hello' ; } location /sub { echo "querystring: $query_string" ; echo "method: $echo_request_method" ; echo "body: $echo_request_body" ; echo "content length: $http_content_length" ; echo '///' ; } # GET /merge?/foo.js&/bar/blah.js&/yui/baz.js will merge the .js resources together location /merge { default_type 'text/javascript' ; echo_foreach_split '&' $query_string; echo "/* JS File $echo_it */" ; echo_location_async $echo_it; echo ; echo_end; } # accessing /if?val=abc yields the "hit" output # while /if?val=bcd yields "miss": location ^~ /if { set $res miss; if ($arg_val ~* '^a' ) { set $res hit; echo $res; } echo $res; } |
这个模块不包含在 Nginx 源码中,安装方法:
1. 首先下载模块源码:https://github.com/agentzh/echo-nginx-module/tags
2. 解压到某个路径,假设为 /path/to/echo-nginx-module
3. 使用下面命令编译并安装 Nginx
1
2
3
4
5
6
7
8
9
10
|
$ wget 'http://sysoev.ru/nginx/nginx-1.0.11.tar.gz' $ tar -xzvf nginx-1.0.11. tar .gz $ cd nginx-1.0.11/ # Here we assume you would install you nginx under /opt/nginx/. $ . /configure --prefix= /opt/nginx \ --add-module= /path/to/echo-nginx-module $ make -j2 $ make install |
试试看吧,该模块是国人 @章亦春 开发的。
http://www.oschina.net/question/12_45735?fromerr=jyurMByB
Nginx 的 Echo 模块 —— echo-nginx-module(转)的更多相关文章
- nginx安装第三方模块echo
要使用第三方模块ngx_echo的功能,请重新配置添加到nginx插件中 ##下载第三方模块 wget https://github.com/openresty/echo-nginx-module/a ...
- nginx 安装 lua_nginx_module 模块(nginx——lua 学习笔记1)
插入两个网站: nginx + lua 的OpenResty 开发 跟我学OpenResty(Nginx+Lua)开发目录贴 两个都是 可以根据目录一步步学习的. 1. 版本下载 nginx版本为 n ...
- nginx之echo模块与内置变量
Nginx扩展第三方模块——echo 第三方模块是对nginx的功能扩展,第三方模块需要在编译nginx的时候使用参数--add-module=PATH指定扩展模块的源码包路径给Nginx扩展添加ec ...
- Nginx 编译 echo 模块
Nginx 编译 echo 模块 echo模块下载地址:https://github.com/openresty/echo-nginx-module 查看nginx已经编译的模块, nginx -V ...
- Nginx SPDY Pagespeed模块编译——加速网站载入
在看<Web性能权威指南>的时候,看到了SPDY这货,于是便开始折腾起了这个了,也顺便把pagespeed加了进去. Nginx SPDY 引自百科~~ SPDY(读作“SPeeDY”)是 ...
- Nginx访问限制模块limit_conn_zone 和limit_req_zone配置使用
nginx可以通过limit_conn_zone 和limit_req_zone两个组件来对客户端访问目录和文件的访问频率和次数进行限制,另外还可以善用进行服务安全加固,两个模块都能够对客户端访问进行 ...
- Nginx详解二十三:Nginx深度学习篇之Nginx+Lua开发环境搭建
Nginx+Lua开发环境 1.下载LuaJIT解释器wget http://luajit.org/download/LuaJIT-2.0.2.tar.gztar -zxvf LuaJIT-2.0.2 ...
- Nginx安装echo模块
echo-nginx-module 模块可以在Nginx中用来输出一些信息,可以用来实现简单接口或者排错. 项目地址:https://github.com/openresty/echo-nginx-m ...
- Aliyun OSS Nginx proxy module(阿里云OSS Nginx 签名代理模块)
1.此文章主要介绍内容 本文主要介绍如何利用Nginx lua 实现将阿里云OSS存储空间做到同本地磁盘一样使用.核心是利用Nginx lua 对OSS请求进行签名并利用内部跳转将所有访问本地Ngin ...
随机推荐
- sql 练习(3)
1.打印九九乘法表 ) ,exp)) A, ,exp))B, ,exp))C, ,exp))D, ,exp))E, ,exp))F, ,exp))G, ,exp))H, ,exp))I from ( ...
- IOS开发之Cocoa编程—— NSUndoManager
在Cocoa中使用NSUndoManager可以很方便的完成撤销操作.NSUndoManager会记录下修改.撤销操作的消息.这个机制使用两个NSInvocation对象栈. NSInvocation ...
- virtualBox文件共享
具体过程,可以参考: http://jingyan.baidu.com/article/2fb0ba40541a5900f2ec5f07.html 共享命令:sudo mount -t vboxsf ...
- rsyslog 直接读取日志,当日志截断后,不会继续发送
rsyslog web机器上日志被截断,那么就不会发送到rsyslog服务器 因为imfile记录了offset,然后你直接>导致offset还没到
- hdu 2563 统计问题
统计问题 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submissi ...
- 化简复杂逻辑,编写紧凑的if条件语句(二):依据if子句顺序化简条件
<化简复杂逻辑,编写紧凑的if条件语句>已经得出了跳.等.飞.异常的各自条件,方便起见这里重新贴一下. 立即跃迁:!a && b && d 等待跃迁:!a ...
- 第七届河南省赛A.物资调度(dfs)
10401: A.物资调度 Time Limit: 2 Sec Memory Limit: 128 MB Submit: 95 Solved: 54 [Submit][Status][Web Bo ...
- linux 下手动编译安装无线网卡驱动
先参照 <本地yum源安装GCC >安装好gcc hp的笔记本上安装了CentOS6.3,没有安装无线网卡驱动,安装这个驱动,在Google上找了好多资料,最后终于解决了这个问题.在这里做 ...
- C#中数组、ArrayList和List三者的区别(转)
好东西,总结的很到位,收藏了! 源地址:http://blog.csdn.net/zhang_xinxiu/article/details/8657431
- ASP.NET动态的网页增删查改
动态页面的增删查改,不多说了,直接上代码 跟前面的一般处理程序一样我上用的同一套三层,只是UI层的东西不一样,在纠结着要不要重新在上一次以前上过的代码: 纠结来纠结去,最后我觉得还上上吧,毕竟不上为我 ...