nginx-Adding the Echo module

Source: Internet
Author: User
Tags echo command

1,nginx's Echo Module introduction

Echo Module is written by the people of the Nginx third-party module, download the official nginx need to download the Echo module, and with Nginx compiled installation, after installation of this module can be in the Nginx URL access through the echo command to output characters to the user's browser, can be used to detect the accessibility of nginx, detect the correctness of nginx configuration, in short, in Debug Configuration Nginx link, the echo command is very useful.

2, download the Echo module source package:

# cd/usr/local/src/# wget https://codeload.github.com/openresty/echo-nginx-module/tar.gz/v0.58 # tar xvzf v0.58# ls ech o-nginx-module-0.58

3. View the parameters of Nginx's existing compilation:

#/opt/nginx/sbin/nginx-vnginx Version:nginx/1.8.1built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) built with OPENSS L 1.0.1c 2012TLS SNI support enabledconfigure arguments:--prefix=/opt/nginx--with-http_ssl_module--with-pcre=/u sr/local/src/pcre-8.37--with-zlib=/usr/local/src/zlib-1.2.8--with-openssl=/usr/local/src/openssl-1.0.1c-- add-module=/usr/local/src/echo-nginx-module-0.58

4. Add the Echo module from the newly compiled Nginx:

#./configure--prefix=/opt/nginx--with-http_ssl_module--with-pcre=/usr/local/src/pcre-8.37--with-zlib=/usr/ local/src/zlib-1.2.8--with-openssl=/usr/local/src/openssl-1.0.1c--add-module=/usr/local/src/ Echo-nginx-module-0.58#make

Note: Do not make install, otherwise it will overwrite the installation nginx.

5, copy the executable file Nginx overwrite the present nginx executable file

#/etc/init.d/nginx stop# CP objs/nginx/opt/nginx/sbin/#/etc/init.d/nginx start

6, verify:

# cat nginx.conf#user  nobody;worker_processes  1;events {     worker_connections  1024;} http {    include       mime.types;      #include        conf.d/vhost.conf;     default_type  application/octet-stream;     #log_format   main    ' $remote _addr -  $remote _user [$time _local]  "$request"        #                   ' $status   $body _bytes_sent  "$http _referer"       #                    ' "$http _user_agent"   " $http _x_forwarded_for "';      #access_log   LOGS/ACCESS.LOG&Nbsp; main;    sendfile        on;     tcp_nopush     on;    keepalive_timeout  65 ;    gzip  on;      server     {    listen 80;    server_name 127.0.0.1;     location / {    echo  "123";    }     access_log logs/tomcat1_access.log;    }}

Access verification:

# Curl 127.0.0.1123

7, note:

1.echo command can only be placed in the URL request, if placed in the URL request, will be an error if the report [Emerg]: "echo" directive is isn't allowed here in, please check the location of Echo placement

2. Once a URL request, echo can only print one line, if there is a logical judgment, and the judgment is successful, then Echo will execute the judgment in the success of the Echo, otherwise execute the last sentence echo (here is not necessarily correct, found in the test is this phenomenon)

3. If ECHO is configured to return or configure Proxy_pass, then echo's output will be overwritten, i.e. the browser cannot see the contents of Echo

4.echo content is not written in the Nginx configuration file, but output to the browser, so the echo of the printed character of the view please view in the browser


This article is from the "Baiyubao blog" blog, make sure to keep this source http://baiyubao.blog.51cto.com/2845008/1758500

nginx-Adding the Echo module

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.