Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

An Nginx module for bringing the power of "echo", "sleep", "time" and more to Nginx's config file

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 src
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README
Octocat-spinner-32 config
README
Description

An nginx module for bringing the power of sh's "echo" command to Nginx's config file.

Installation

Grab the nginx source code from http://nginx.net/ , for example,
the version 0.8.17 and then build the source with this module:

    $ wget 'http://sysoev.ru/nginx/nginx-0.8.17.tar.gz'
    $ tar -xzvf nginx-0.8.17.tar.gz
    $ cd nginx-0.8.17/
    $ ./configure --prefix /opt/nginx \
        --add-module=/path/to/echo-nginx-module

Configuration

This is a sample configuration snippet in your nginx.conf file:

    http {
        ...
        server {
            ...

            default_type text/plain;

            location /hello {
                echo 'hello, world';
                echo hello world;
            }

            location /echoback {
                echo "------------------------";
                echo_client_request_header;
            }

            location /server {
                echo "Server name: $server_name";
                echo "Server address: $server_addr";
                echo "Server port: $server_port";
                echo "Server protocol: $server_protocol";
            }
            ...
        }
        ...
    }

As you can see, the only directive provided by this module is
"echo".

After starting the nginx server, one can query it these ways:

    $ curl 'http://localhost/hello'
    hello, world
    hello world

    $ curl 'http://localhost/echoback'
    ------------------------
    GET /echoback HTTP/1.1
    User-Agent: curl/7.18.2 (i486-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.10
    Host: localhost
    Accept: */*

    $ curl 'http://localhost/server'
    Server name: localhost
    Server address: 127.0.0.1
    Server port: 80
    Server protocol: HTTP/1.1

Contact the author by agentzh at gmail dot com whenever you have
any questions.

Something went wrong with that request. Please try again.