logo

mod_evasive:DDoS対策モジュール

DOSPageInterval

「DOSPageCount」の設定値(秒)

DOSPageCount

リクエストできるページリロード回数の上限

DOSSiteCount

リクエストできるページ数の上限

DOSSiteInterval

「DOSSiteCount」の設定値(秒)

DOSBlockingPeriod

IPアドレスを遮断する時間(秒)。この遮断されている間のアクセスには403 (Forbidden)を返します

DOSWhitelist

ホワイトリスト、IPアドレスベースで記述 設定例 [#i8ee469a]

One minute to read

mod_extract_forwarded:Pound環境下のApacheのログにリモートのIPアドレスを記録

Dependencies Resolved

===================================================================================================== Package Arch Version Repository Size

Installing: mod_extract_forwarded x86_64 2.0.2-8.el6 epel 15 k

Transaction Summary

Install 1 Package(s)

Total download size: 15 k Installed size: 29 k Is this ok [y/N]: y Downloading Packages: mod_extract_forwarded-2.0.2-8.el6.x86_64.rpm | 15 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : mod_extract_forwarded-2.0.2-8.el6.x86_64 1/1 Verifying : mod_extract_forwarded-2.0.2-8.el6.x86_64 1/1

Installed: mod_extract_forwarded.x86_64 0:2.0.2-8.el6

Complete! [root@master01 conf.d]# pwd /etc/httpd/conf.d [root@master01 conf.d]# ls -l 合計 40 -rw-r–r– 1 root root 392 8月 14 02:30 2013 README -rw-r–r– 1 root root 2699 7月 30 07:10 2011 mod_extract_forwarded.conf [root@master01 conf.d]# cp -p mod_extract_forwarded.conf mod_extract_forwarded.conf.org [root@master01 conf.d]# vi mod_extract_forwarded.conf

MEFaccept 1.2.3.4 1.2.3.5

MEFaccept 127.0.0.1 [root@master01 conf.d]# service httpd configtest Syntax OK [root@master01 conf.d]# service httpd graceful [root@master01 conf.d]# tail -f /var/log/httpd/www.inamuu.com-access.log 182.249.. - - [28/Jan/2014:12:21:34 +0900] "GET /favicon.ico HTTP/1.1" 302 302 "-" "MobileSafari/9537.53 CFNetwork/672.0.8 Darwin/14.0.0"

↑携帯のIPアドレスがログに記述されるようになりました。 参考URL:http://futuremix.org/2012/01/pound-apache-ip-address

2 minutes to read

mod_rewrite:リダイレクト処理

-同じドメインの別ディレクトリにあるファイルへのリダイレクト

-別ドメインのアドレスへリダイレクト処理を実施する。

-別ドメインのアドレスをリダイレクト処理する(AからBへ)

-index.phpとindex.htmlのアクセスを統一させる。

-特定のページのみアクセスを許可する

-トップページへのアクセスのみリダイレクト

-スマフォサイトへリダイレクトする記述

-あるディレクトリへのアクセスの際に、そのディレクトリの配下の別のディレクトリへリダイレクト

-スラッシュの有無の統一

-URLの書き換え www有りへの統一

-URLの書き換え www無しへ統一

-特定のディレクトリの配下のみサブドメインを統一する

-Apacheでhttp://*のアクセスを全てhttps://にリダイレクトする方法

-特定のディレクトリのみhttpsへリダイレクトし、それ以外はhttpでアクセスさせる方法

-Pound配下の場合

-同一ディレクトリ内の別のディレクトリは除外して、当該ディレクトリへのアクセスはリダイレクトする方法

-CGIなどのGETパラメータを持っているURLを同じパラメータのURLへ書き換え

-例:メンテナンスで社外からはメンテナンスページを表示させて、社内から通常どおりアクセスさせたい場合

-存在しない複数URLに対して

-例2.別のドメインやURLにリダイレクトする

-注意事項

RewriteEngine on RewriteCond %{REMOTE_ADDR} !^192.168.1.99$ RewriteCond %{REMOTE_ADDR} !^192.168.1.100$ RewriteCond %{REQUEST_URI} !^/maint/index.html RewriteRule ^.*$ /maint/index.html [R=503,L] フラグの意味 [#o3095730]

3 minutes to read

mod_rpaf:LB配下でも正しい接続元IPアドレスをログに取得する

RPAFenable "On"に設定すると、このモジュールの機能が有効になる。 RPAFsethostname "On"に設定すると、リバースプロキシが付与するヘッダX-Forwarded-HostあるいはX-Hostの値をHostヘッダの値として設定する。 RPAFproxy_ips リバースプロキシのIPアドレスをスペース区切りで列挙する。オリジナルにはない付加機能として"10."や"172.16."のようなドットで終わるサブネットの記法も使える。なお、この範囲を可能な限り限定してください。リバースプロキシを経由しないアクセス経路があるときには、X-Forwarded-Hostヘッダの偽装の影響を受ける恐れがある。 RPAFheader リバースプロキシが付与するアクセス元IPアドレスを格納しているヘッダ名を記述する。デフォトではX-Forwarded-Forが使われる。

service httpd configtest

service httpd graceful

httpd -M

One minute to read

mod_spamhaus:DDoS対策SPAMHAUSの参照

cd /usr/local/src

wget http://downloads.sourceforge.net/project/mod-spamhaus/mod-spamhaus/0.7/mod-spamhaus-0.7.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmod-spamhaus%2F&ts=1385709161&use_mirror=jaist

tar xfvz mod-spamhaus-0.7.tar.gz

cd mod-spamhaus

which apxs2

/usr/bin/which: no apxs2 in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

which apxs

/usr/sbin/apxs

vi Makefile

APXS=apxs2 > APXS=apxs

make

apxs -Wc, -Wc,-DDST_CLASS=3 -c src/mod_spamhaus.c /usr/lib64/apr-1/build/libtool –silent –mode=compile gcc -prefer-pic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector –param=ssp-buffer-size=4 -m64 -mtune=generic -Wformat-security -fno-strict-aliasing -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/httpd -I/usr/include/apr-1 -I/usr/include/apr-1 -DDST_CLASS=3 -c -o src/mod_spamhaus.lo src/mod_spamhaus.c && touch src/mod_spamhaus.slo src/mod_spamhaus.c: In function ‘update_whitelist’: src/mod_spamhaus.c:127: 警告: statement with no effect src/mod_spamhaus.c:139: 警告: ignoring return value of ‘fgets’, declared with attribute warn_unused_result src/mod_spamhaus.c: In function ‘check_whitelist’: src/mod_spamhaus.c:174: 警告: statement with no effect src/mod_spamhaus.c: In function ‘core’: src/mod_spamhaus.c:249: 警告: statement with no effect src/mod_spamhaus.c: In function ‘white_list_conf’: src/mod_spamhaus.c:328: 警告: statement with no effect src/mod_spamhaus.c:339: 警告: statement with no effect src/mod_spamhaus.c: In function ‘dns_to_query’: src/mod_spamhaus.c:351: 警告: statement with no effect src/mod_spamhaus.c: In function ‘looking_for’: src/mod_spamhaus.c:363: 警告: statement with no effect src/mod_spamhaus.c: In function ‘num_cached_ip’: src/mod_spamhaus.c:374: 警告: statement with no effect src/mod_spamhaus.c: In function ‘custom_err_cfg’: src/mod_spamhaus.c:388: 警告: statement with no effect src/mod_spamhaus.c: In function ‘add_cache’: src/mod_spamhaus.c:237: 警告: 制御が非 void 関数の終りに到達しました /usr/lib64/apr-1/build/libtool –silent –mode=link gcc -o src/mod_spamhaus.la -rpath /usr/lib64/httpd/modules -module -avoid-version src/mod_spamhaus.lo

write "make install" to install module

make install

apxs -Wc, -Wc,-DDST_CLASS=3 -i -a -n spamhaus src/mod_spamhaus.la /usr/lib64/httpd/build/instdso.sh SH_LIBTOOL='/usr/lib64/apr-1/build/libtool' src/mod_spamhaus.la /usr/lib64/httpd/modules /usr/lib64/apr-1/build/libtool –mode=install cp src/mod_spamhaus.la /usr/lib64/httpd/modules/ libtool: install: cp src/.libs/mod_spamhaus.so /usr/lib64/httpd/modules/mod_spamhaus.so libtool: install: cp src/.libs/mod_spamhaus.lai /usr/lib64/httpd/modules/mod_spamhaus.la libtool: install: cp src/.libs/mod_spamhaus.a /usr/lib64/httpd/modules/mod_spamhaus.a libtool: install: chmod 644 /usr/lib64/httpd/modules/mod_spamhaus.a libtool: install: ranlib /usr/lib64/httpd/modules/mod_spamhaus.a libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/sbin" ldconfig -n /usr/lib64/httpd/modules

Libraries have been installed in: /usr/lib64/httpd/modules

If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the -LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the LD_RUN_PATH' environment variable during linking - use the -Wl,-rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages.

chmod 755 /usr/lib64/httpd/modules/mod_spamhaus.so [activating module `spamhaus' in /etc/httpd/conf/httpd.conf]

cd /etc/httpd/conf/

view httpd.conf

LoadModule spamhaus_module /usr/lib64/httpd/modules/mod_spamhaus.so

cp -p hogehoge.conf hogehoge.conf.date +%Y%m%d <==設定ファイルをコピー

vi hogehoge.conf <==対象の設定ファイルを参照。VirtualHostであればそのconfファイルに書く。

<IfModule mod_spamhaus.c> MS_METHODS POST,PUT,OPTIONS,CONNECT #MS_WhiteList /etc/spamhaus.wl MS_WhiteList /etc/httpd/conf.d/spamhaus.wl #MS_Dns local.rbldnsd.instance.of.sbl-xbl MS_CacheSize 256 #MS_CustomError "My custom error" </IfModule>

service httpd configtest

service httpd graceful

2 minutes to read

mongodb

One minute to read