nginxのモジュールを説明します

nginxの公式モジュール、サードパーティモジュール:nginxのモジュールが分かれています

nginxの-Vコンパイラのパラメータを参照することで、あなたはモジュールの公式のコンパイルを見ることができます

--with-compat 
--with-file-aio 
--with-threads 
--with-http_addition_module 
--with-http_auth_request_module 
--with-http_dav_module 
--with-http_flv_module 
--with-http_gunzip_module 
--with-http_gzip_static_module 
--with-http_mp4_module 
--with-http_random_index_module 
--with-http_realip_module 
--with-http_secure_link_module 
--with-http_slice_module 
--with-http_ssl_module 


--with-http_stub_status_module 
作用:nginx的客户端连接状态
Syntax:stub_status;
Default:——
Context:server,location
--with-http_sub_module 
--with-http_v2_module 
--with-mail 
--with-mail_ssl_module 
--with-stream 
--with-stream_realip_module 
--with-stream_ssl_module 
--with-stream_ssl_preread_module 
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong 
--param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' 
--with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'

--with-http_stub_status_module
効果:nginxのクライアントの接続状態

構文:stub_status

デフォルト: -

コンテキスト:サーバ、場所

デモ:

我々は/etc/nginx/conf.d/default.conf

図1に示した構成:

位置/ mystatus {
        stub_status。
        }

設定が正しい使用します

nginxの-tc /etc/nginx/nginx.conf

その後、リロードサービス

nginxの-sリロード-c /etc/nginx/nginx.conf

ブラウザで+パスを入力したIP

http://192.168.96.188/mystatus

Active connections: 1    #当前活跃的连接数
server accepts handled requests
 1 1 1    # 第一个值代表握手总次数;第二个值代理处理的连接数;第三个值是总的请求数;(握手次数一般都等于连接数,代表连接没有丢失)
Reading: 0 Writing: 1 Waiting: 0 #读、写、等待

--with-http_random_index_module

役割:ランダムホームページのディレクトリを選択します。

構文:上random_index | オフ

デフォルト:random_indexオフ

コンテキスト:場所

デモ:

HTMLファイルは、3 1.htmlでは/ opt /アプリ/コードディレクトリ、2.html、3.htmlを定義します

それぞれ、以下のコードをコピーし

<html>
<head>
        <meta charset="utf-8">
        <title>imooc1</title>
</head>
<body style="">        # 红色
</body>
</html>


<html>
<head>
	<meta charset="utf-8">
	<title>imooc1</title>
</head>
<body style="">        #黑色
</body>
</html>


<html>
<head>
	<meta charset="utf-8">
	<title>imooc1</title>
</head>
<body style="">      #蓝色
</body>
</html>


設定ファイルを変更します。

我々は/etc/nginx/conf.d/default.conf

 location / {
        root   /opt/app/code;
        random_index on;
        #index  index.html index.htm;
    }

設定が正しいか確認してください

nginxの-tc /etc/nginx/nginx.conf

その後、リロードサービス

nginxの-sリロード-c /etc/nginx/nginx.conf

ブラウザでのIPアクセス、ページを更新し、色が変わります

--with-http_sub_module

役割ます:http置き換え

#1の構文

構文:sub_filter列置換

デフォルト: -

コンテキスト:HTTP、サーバー、場所

#2構文

構文:上sub_filter_last_modified |オフ

デフォルト:オフsub_filter_last_modified

コンテキスト:サーバ、場所

#3構文

構文:上sub_filter_last_once | オフ

デフォルト:上sub_filter_last_once

コンテキスト:HTTP、サーバー、場所

デモ:

/ opt /アプリ/コードディレクトリにhtmlファイルを追加します

复制如下代码,保存
<html>
<head>
        <meta charset="utf-8">
        <title>submodules</title>
</head>
<body>
        <a>joy</a>
        <a>at</a>
        <a>imooc</a>
        <a>joy</a>
        <a>imooc</a>
</head>
</body>
</html>

アクセス192.168.96.188/submodule.html。

設定構文によって「IMOOC_JOY」の「imooc」」コンテンツを交換します

我々は/etc/nginx/conf.d/default.conf

次のコードを追加します。

location / {
   root   /opt/app/code;
   index  index.html index.htm;
   sub_filter '<a>imooc' '<a>IMOOC_JOY';  #sub_filter 后面添加需要替换内容,已经替换后的内容
    }

アクセス192.168.96.188/submodule.html

デフォルトのみを交換します

あなたは、すべての追加新しい構文を交換した場合

location / {
        root   /opt/app/code;
        index  index.html index.htm;
        sub_filter '<a>imooc' '<a>IMOOC_JOY';
        sub_filter_once off;        #在原有基础加上此模块,off 关闭
    }

アクセスアドレス保存し、すべての内容を置き換える、強いブラシを覚えているか、キャッシュをきれいに

おすすめ

転載: www.cnblogs.com/joy-sir/p/12162379.html