Nginxでアクセス制限

今更感はありますが、
WordPressの16万サイトが大規模攻撃の踏み台に、「Pingback」機能悪用

Apacheなら結構出てくるのですが、
Nginxのアクセス制限ってあまり見かけないのでやってみた。

WordPressのPinbackを停止する方法もありますが、
どうせならサーバ側でやってしまおう!!


ファイルの場合

server {
        listen 80;
        root /hoge/web;
        index index.php;
        server_name www.neko6.info;

        location ~ \.php$ {
                include fastcgi_params;
                fastcgi_pass    unix:/var/run/php5-fpm.sock;
                fastcgi_index   index.php;
                fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        	location  ~* /deny_file\.php$ {
                	deny all;
                	allow 172.0.0.1;
        		}
	}
}

こんな感じにphpの中に追加してやる。

ディレクトリの場合

server {
        listen 80;
        root /hoge/web;
        index index.php;
        server_name www.neko6.info;

        location ~ \.php$ {
                include fastcgi_params;
                fastcgi_pass    unix:/var/run/php5-fpm.sock;
                fastcgi_index   index.php;
                fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
	}
        location  ~* /deny_dir/ {
                deny all;
                allow 172.0.0.1;
        }
}

こんな感じでServerの中に追加してやる。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

Enter code * Time limit is exhausted. Please reload CAPTCHA.

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください