Nginx安裝echo模塊


1、下載需要的echo模塊
https://github.com/openresty/echo-nginx-module/tags
# wget https://github.com/openresty/echo-nginx-module/archive/v0.60.tar.gz
# tar zxvf v0.60.tar.gz
# mv echo-nginx-module-0.60 tools/

2、安裝nginx
# wget http://nginx.org/download/nginx-1.10.1.tar.gz
# tar -zxvf nginx-1.10.1.tar.gz
# /application/nginx/sbin/nginx -V    #查看已經安裝過的模塊

3、安裝echo-nginx模塊
# ./configure --add-module=/root/tools/echo-nginx-module-0.60 #安裝echo模塊(文件夾名echo-nginx-module-0.60)
# make #開始編譯,但別安裝 (make install會直接覆蓋安裝)
注意先備份一下之前老的,手動安裝一下。
# mv /application/nginx/sbin/nginx /application/nginx/sbin/nginx.old
# make upgrade    #平滑升級
# make install        #全新安裝
# make clean        #(清除操作,可以忽略)

4、ngix_echo模塊的使用
location /echo {
default_type text/html;
set $foo 'hello world';     #自定義變量
echo "$request_uri";      #顯示nginx全局變量的內容
echo </br>$foo;             #顯示自定義變量的內容
}

5、nginx全局變量
$args :                     #這個變量等於請求行中的參數,同$query_string
$content_length :    #請求頭中的Content-length字段。
$content_type :       #請求頭中的Content-Type字段。
$document_root :   #當前請求在root指令中指定的值。
$host :                     #請求主機頭字段,否則為服務器名稱。
$http_user_agent :  #客戶端agent信息
$http_cookie :          #客戶端cookie信息
$limit_rate :              #這個變量可以限制連接速率。
$request_method :   #客戶端請求的動作,通常為GET或POST。
$remote_addr :         #客戶端的IP地址。
$remote_port :          #客戶端的端口。
$remote_user :         #已經經過Auth Basic Module驗證的用戶名。
$request_filename : #當前請求的文件路徑,由root或alias指令與URI請求生成。
$scheme :                #HTTP方法(如http,https)。
$server_protocol :    #請求使用的協議,通常是HTTP/1.0或HTTP/1.1。
$server_addr :         #服務器地址,在完成一次系統調用后可以確定這個值。
$server_name :       #服務器名稱。
$server_port :          #請求到達服務器的端口號。
$request_uri :          #包含請求參數的原始URI,不包含主機名,如:”/foo/bar.php?arg=baz”。
$uri :                        #不帶請求參數的當前URI,$uri不包含主機名,如”/foo/bar.html”。
$document_uri :      #與$uri相同

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM