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# igorlocation /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 requestlocation /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 togetherlocation /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 ...
随机推荐
- SQLServer .mdf和.ldf文件
.mdf:是数据库数据文件,存放一个数据库的数据信息. .ldf:是数据库日志文件,即日常对数据库的操作的记录如(增.删.改)的文件.
- PHP 单列模式实例讲解以及参考网址
1,http://blog.csdn.net/jungsagacity/article/details/7618587 2,http://www.cnblogs.com/lh460795/archiv ...
- SQL类型转换以及自动在前面补0满足10位工号标示法
1,自动在前面补0满足10位工号标示法 SELECT rtrim(ltrim(right(cast('00000000'+rtrim(CAST(数值 as int)) as varchar(20)), ...
- Asp.Net请求处理机制中IsApiRuntime解析
今天看了web请求的生命周期,看完了还有些不懂,就是用反编译工具,查看封装内库的内部实现. 从计算机内部查到web.dll,使用反编译工具打开 打开后 public int ProcessReques ...
- Servlet基础知识(四)——Servlet过滤器Filter
一.什么是过滤器: 政府大楼的安检保安,它既能对进入政府大楼的人员进行检查,只允许检查符合要求的进入:同时他也负责对出大楼的人进行检查,看他带出的东西是否符合要求. 同样的,Servlet中的过滤器既 ...
- Python: how to public a model
1, Create a folder fileFolder 2, create a file tester.py 3, create another file setup.py: The conten ...
- 每天一个小算法(5)----找到链表倒数第K个结点
估计这个问题在面试中被问烂了. 思路是先找到正数的第K个结点的指针pT,然后和指向头结点的指针pN一起向后移动,直到第K个指针指向NULL,此时pN指向的结点即倒数第K个结点. 如图: #includ ...
- iphone 4 safrai fixed
<script type="text/javascript"> if(navigator.userAgent.indexOf("Safari")&g ...
- Umbraco学习1------安装
最近在做一个公益项目,考虑到成本和性价比,最终决定还是选用Umbraco作为CMS平台进行开发. 顺便也借机将Umbraco的使用整理成系列,便于以后的记忆. Umbraco的所有信息,基本都可以在h ...
- QTreeView处理大量数据(使用1000万条数据,每次都只是部分刷新)
如何使QTreeView快速显示1000万条数据,并且内存占用量少呢?这个问题困扰我很久,在网上找了好多相关资料,都没有找到合理的解决方案,今天在这里把我的解决方案提供给朋友们,供大家相互学习. 我开 ...