• Stars
    star
    200
  • Rank 194,673 (Top 4 %)
  • Language
    C
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple Nginx echo module

Practical development Nginx Module

Build Status

简体中文

nginx_module_echo

echo string

Nginx Version

Nginx1.0.10 https://github.com/nginx/nginx/releases/tag/release-1.0.10 nginx1.0.10.png

The development environment configuration

OS : CentOS Linux release 7.2.1511 (Core)

Server_info.png Server_CPU_info.png

Install a clean compile Nginx

  1. Download a Nginx10.10 and unpack it nginx1.0.10.png

  2. Install the GCC and the lib Nginx need install_GCC.png Nginx_lib.png

  3. ./configure --prefix=/usr/local/nginx && make && make install configure_ok.png make && make install.png nginx_install_ok.png

  4. Nginx run start_nginx.png nginx_install_ok.png

Definition module configuration structure

typedef struct {
    ngx_str_t ed;  //该结构体定义在这里 https://github.com/nginx/nginx/blob/master/src/core/ngx_string.h
} ngx_http_echo_loc_conf_t;

define_moudle_conf.png

Define Nginx instruction and parameter conversion function

定义指令和参数转化函数.png

definition module Context

  1. Define the type of ngx_http_module_t structure variables 定义注入点结构体.png
  2. Initialize a configuration structure 初始化一个配置结构体.png
  3. Will the father block configuration information incorporated into this structure Implement the configuration of inheritance 合并父block的配置信息.png

Write the Handler really work part of the module

Nginx模块handler.png

Combination Nginx module

组合Nginx Module.png

Finishing module code According to the Nginx official specification

ok_file.png

Write the config file

ngx_addon_name=ngx_http_echo_module
HTTP_MODULES="$HTTP_MODULES ngx_http_echo_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/src/ngx_http_echo_module.c"

make && make install

 ./configure --prefix=/usr/local/nginx/ --add-module=/root/ngx_dev && make && make install

Successful installation

make install.png

Modify the Nginx configuration file test Module

test module.png

Nginx echo Module The successful running

module ok.png

If the repo help you welcome star fork Thanks!

reference

  1. http://wiki.nginx.org/Configuration
  2. http://tengine.taobao.org/book/
  3. http://blog.codinglabs.org/articles/intro-of-nginx-module-development.html
  4. https://www.nginx.com/resources/wiki/modules/

More Repositories

1

dingtalk-exception

Laravel/Lumen exception notify through DingTalk
PHP
93
star
2

panda

A simple extension for PHP
C
45
star
3

php-cli-color

Simple and easy to use the PHP command-line output of color
PHP
40
star
4

php-geo

php geo library
PHP
35
star
5

onlineDisk_search

网盘搜索引擎
PHP
27
star
6

Fphp

a micro php MVC framework
PHP
26
star
7

web-eyes

18 lines of code implement a Web fingerprint identification Web Server.
JavaScript
26
star
8

redis-module-panda

A simple redis module, Just for fun
C
18
star
9

wujunze.com

My blog daily update and maintenance
PHP
14
star
10

laravel-id-generate

Laravel package to generate and to validate a UUID according to the RFC 4122 standard and generate SnowFlake Id
PHP
13
star
11

PandaProxy

A simple Network Proxy written by Go
Go
10
star
12

money-wrapper

MoneyPHP Wrapper
PHP
10
star
13

ASRock-Z370-Pro4-9900K-Hackintosh

ASRock-Z370-Pro4 9900K Hackintosh
8
star
14

10010-collect

联通通话记录抓取
PHP
7
star
15

awesome-swoft

A curated list of bookmarks, packages, tutorials, videos and other cool resources from the Swoft ecosystem
6
star
16

http-client

Http client component base on GuzzleHttp For convenience
PHP
5
star
17

laravel-debug-helper

Laravel package to help debug
PHP
5
star
18

no-hard-blockchain

No hard blockchain
5
star
19

apollo-laravel-client

Apollo configuration management Laravel client
PHP
5
star
20

learning

Keep learning to keep progress
PHP
4
star
21

declare-strict-easy

PHP7 tool for easy add/remove "declare(strict_types=1)"
PHP
3
star
22

Hackathon_ml

2016年segmenfault Hackathon 参赛项目(By:the Black Pearl)
JavaScript
3
star
23

composer-phpcs-plugin

Composer plugin for code style checking before commit using php-cs-fixer
PHP
3
star
24

phpExcelReader

Optimize phpExcelReader php7 make its support
PHP
3
star
25

wujunze

Magic profile
3
star
26

codemore-daily

收集相关技术文章做推荐
2
star
27

AWTRIX2.0-App-DAOFM

DAOFM APP for AWTRIX2.0
VBA
2
star
28

sentry-weapp

Wechat WeApp SDK for Sentry https://sentry.io
JavaScript
2
star
29

laravel-sentry

[WIP] The Laravel Sentry package.
PHP
2
star
30

wujunze.github.io

blog source
HTML
2
star
31

blog-images

Graph bed for my blog
2
star
32

luci-app-autoshutdown

Lua
2
star
33

go-smart-cache

go cache tool
1
star
34

http

A simple http client for golang
Go
1
star
35

conf

常用的配置文件(也是为了备份)
1
star
36

easy-os

Lean OS
Assembly
1
star