echo-nginx-module

 

 


echo-nginx-module

 

Compile

# Version: Ubuntu-16.04, nginx-1.15.12, echo-nginx-module-0.61

mkdir /usr/src/nginx; cd /usr/src/nginx;

wget https://github.com/openresty/echo-nginx-module/archive/v0.61.zip

unzip v0.61.zip

cd nginx-1.15.12

./configure --prefix=/opt/nginx \
 ... \                   # setting must same as first build
 --add-dynamic-module=/usr/src/nginx/echo-nginx-module-0.61

make

cp ./objs/ngx_http_echo_module.so /opt/nginx/modules/

Setting

nginx.conf

load_module "modules/ngx_http_echo_module.so";
...

Example

sites-enabled/proxy_www

server {
  listen 8888;
  ...

  # Example 1
  location = /404 { add_header Content-Type text/html; echo "404"; }

  # Example 2
  location ~ ^/r/([0-9a-zA-Z]+) { echo $1;}

  # Example 3
  location /testing {
    set $message "Hello Buddy";
    # newlines (\n) and tabs (\t)
    echo "Testing this amazing Feature: $message";
  }
}