Skip to content
练习Nginx模块开发,handler / filter / upstream / subrequest / etc...
C
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
README.md
config

README.md

practice-nginx-module

练习 Nginx 模块开发知识点

安装

目录

print

可用print指令输出内容,格式:print 参数1 参数2 ***,可带任意个参数,将响应参数内容:

location /print{
    print hello world nihao shijie;
}

响应:

curl http://localhost/print
$ hello world nihao shijie;

add_content

可用add_content指令在响应体前添加一段:[content add by filter],主要练习 nginx http 过滤器。 指令:add_content on|off;

location /print{
    print hello world;
    add_content on;
}

响应:

$ curl http://localhost/print 
[content add by filter]
hello world  

practice_upstream

可用practice_upstream 指令调用 Nginx upstream 功能访问上游服务器。这里硬编码游服务器为 localhost/print 示例:

location /print{
    print hello world;
}

location /practice_upstream{
   practice_upstream;
}

响应:

$ curl http://localhost/practice_upstream
hello world  

todo

  • print 可输出变量,如print $request_uri;
You can’t perform that action at this time.