Ⅰ. はじめに
タイトルの通り「nginxでフィルタを設定する方法」です。
Ⅱ. 手順
1. confファイルを開く
/etc/nginx/conf.d/default.conf
server { listen 80; server_name example.com; location / { # フィルタを一度のみ適応 sub_filter_once on; # フィルタを全てのMIMEタイプに適応(デフォルトはtext/htmlのみ) # sub_filter_types *; # フィルタ sub_filter '</head>' '<script>alert("helloworld")</script></head>'; } }
実行結果
省略