天天看點

nginx狀态子產品詳解及實戰

nginx status介紹

    nginx軟體的功能子產品中有一個ngx_http_stub_status_module子產品,這個子產品的主要功能是記錄nginx的基本通路狀态資訊,讓使用者了解nginx的工作狀态,例如:連接配接數等資訊。要想使用狀态子產品,在編譯nginx時必須增加http_stub_status_module支援。

    可通過如下方法檢查編譯安裝nginx時是否設定支援上述子產品支援:

<code>[root@web01 extra]</code><code># /application/nginx/sbin/nginx -V #檢查編譯安裝時設定的編譯參數</code>

<code>nginx version: nginx</code><code>/1</code><code>.6.3</code>

<code>built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) </code>

<code>TLS SNI support enabled</code>

<code>configure arguments: --user=www --group=www --with-http_ssl_module --with-http_sub_module --prefix=</code><code>/application/nginx-1</code><code>.6.3/</code>

    上述可以檢視編譯的時候沒有安裝 --with-http_stub_status_module     enable ngx_http_stub_status_module  狀态子產品。

直接生成status.conf配置檔案

<code>[root@web01 extra]</code><code># vim /application/nginx/conf/extra/status.conf </code>

<code>#status</code>

<code>server{</code>

<code>        </code><code>listen 80;</code>

<code>        </code><code>server_name status.etiantian.org;</code>

<code>        </code><code>location / {</code>

<code>        </code><code>stub_status on;</code>

<code>        </code><code>access_log off;</code>

<code>     </code><code>}</code>

<code>  </code><code>}</code>

<code>[root@web01 extra]</code><code># /application/nginx/sbin/nginx -s reload</code>

    在window中C:\Windows\System32\drivers\etc\hosts再增加一個域名解析:10.0.0.8 status.etiantian.org

    然後在windows的ie中通路status.etiantian.org,會出現如下資訊:

<a href="https://s5.51cto.com/wyfs02/M02/9E/E6/wKioL1mZNcqyN2XtAABsHzP6Khc640.jpg" target="_blank"></a>

    當然也可以限制檢視狀态

<a href="https://s4.51cto.com/wyfs02/M01/9E/E6/wKioL1mZNqaD4Di2AAB1-cndwfw713.jpg" target="_blank"></a>

<a href="https://s2.51cto.com/wyfs02/M02/9E/E6/wKioL1mZNyOy1STEAACsMxSVFyM033.jpg" target="_blank"></a>

<a href="https://s2.51cto.com/wyfs02/M00/00/36/wKiom1mZNyrDezdJAABk4hv4kQc980.jpg" target="_blank"></a>

本文轉自sandshell部落格51CTO部落格,原文連結http://blog.51cto.com/sandshell/1957818如需轉載請自行聯系原作者

sandshell

繼續閱讀