« ソフトバンクの「みまもりケータイ」シリーズの機能比較と「みまもりケータイ3」のSMSによる管理モードについて | トップページ | NHK総合テレビ「おはよう日本」内のコーナー番組「世界のニュースザッピング」2014年5月のまとめ »

2014/05/17

Apacheの.htaccessによるアクセス制限について調べてみた

個人でVPS(Virtual Private Server)を契約しています.一箇所は日本の某社,もうひとつはアメリカの激安VPS.logwatchで毎日監視したり,denyhostsをインストールして不正なログインを弾いているのですが,それでも結構なアクセスが海外からやってきます.

というわけで今回はCentOS6.5(64bit)とApache2.2.15(Unix)を使った.htaccessによるアクセス制限のかけ方について書いておきます.ほとんど自分宛の覚え書きなのでわからない人はスルーして下さい.

ある日のlogwachから.

--------------------- httpd Begin ------------------------ Requests with error response codes 403 Forbidden /: 2 Time(s) http://proxyjudge.info: 1 Time(s) 404 Not Found //3rdparty/phpMyAdmin/scripts/setup.php: 2 Time(s) //PMA2005/scripts/setup.php: 3 Time(s) //_admin/scripts/setup.php: 2 Time(s) //_phpmyadmin/scripts/setup.php: 2 Time(s) //admin/mysql/scripts/setup.php: 2 Time(s) //admin/phpmyadmin/scripts/setup.php: 5 Time(s) //admin/pma/scripts/setup.php: 5 Time(s) //admin/scripts/setup.php: 6 Time(s) //administrator/components/com_joommyadmin ... ripts/setup.php: 2 Time(s) //adminmysql/scripts/setup.php: 2 Time(s) //admm/scripts/setup.php: 5 Time(s) //admn/scripts/setup.php: 5 Time(s) //apache-default/phpmyadmin/scripts/setup.php: 2 Time(s) //backup/phpmyadmin/scripts/setup.php: 2 Time(s) //bbs/data/scripts/setup.php: 2 Time(s) //bkup/phpmyadmin/scripts/setup.php: 2 Time(s) //blog/phpmyadmin/scripts/setup.php: 2 Time(s) //cpadmin/scripts/setup.php: 2 Time(s) //cpadmindb/scripts/setup.php: 2 Time(s) //cpanelmysql/scripts/setup.php: 2 Time(s) //cpanelphpmyadmin/scripts/setup.php: 2 Time(s) //cpanelsql/scripts/setup.php: 2 Time(s) //cpdbadmin/Anonymous/scripts/setup.php: 2 Time(s) //cpdbadmin/scripts/setup.php: 2 Time(s) //cpphpmyadmin/scripts/setup.php: 2 Time(s) //database/scripts/setup.php: 2 Time(s) //databaseadmin/scripts/setup.php: 5 Time(s) //db/scripts/setup.php: 5 Time(s) //dbAdmin2/scripts/setup.php: 2 Time(s) //dbadmin/scripts/setup.php: 5 Time(s) //forum/phpmyadmin/scripts/setup.php: 2 Time(s) //htdocs/scripts/setup.php: 2 Time(s) //myadmin/scripts/setup.php: 5 Time(s) //mydatadmin/scripts/setup.php: 2 Time(s) //mysql-admin/scripts/setup.php: 5 Time(s) //mysql/scripts/setup.php: 5 Time(s) //mysqladmin/: 1 Time(s) //mysqladmin/scripts/setup.php: 7 Time(s) //mysqladminconfig/scripts/setup.php: 2 Time(s) //mysqlmanager/scripts/setup.php: 5 Time(s) //p/m/a/scripts/setup.php: 5 Time(s) //padmin/scripts/setup.php: 2 Time(s) //php-my-admin/scripts/setup.php: 8 Time(s) //php-myadmin/scripts/setup.php: 5 Time(s) //php/phpmyadmin/scripts/setup.php: 2 Time(s) //php/scripts/setup.php: 2 Time(s) //phpMyAdmi/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.2.3/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.2.6/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.5.1/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.5.4/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.5.5-pl1/index.php: 1 Time(s) //phpMyAdmin-2.5.5-pl1/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.5.5-rc1/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.5.5-rc2/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.5.5/index.php: 1 Time(s) //phpMyAdmin-2.5.5/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.5.6-rc1/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.5.6-rc2/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.5.6/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.5.7-pl1/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.5.7/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.0-alpha/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.0-alpha2/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.0-beta1/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.0-beta2/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.0-pl1/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.0-pl2/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.6.0-pl3/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.0-rc1/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.0-rc2/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.0-rc3/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.0/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.1-pl1/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.6.1-pl2/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.6.1-rc1/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.1-rc2/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.1/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.6.2-beta1/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.6.2-pl1/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.6.2-rc1/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.6.2/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.6.3-pl1/scripts/setup.php: 1 Time(s) //phpMyAdmin-2.6.3-rc1/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.6.3/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.4-pl1/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.4-pl2/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.4-pl3/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.6.4-pl4/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.4-rc1/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.6.4/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.7.0-beta1/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.7.0-pl1/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.7.0-pl2/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.7.0-rc1/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.7.0/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.8.0-beta1/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.8.0-rc1/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.8.0-rc2/scripts/setup.php: 2 Time(s) //phpMyAdmin-2.8.0.1/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.8.0.2/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.8.0.3/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.8.0.4/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.8.0/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.8.1-rc1/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.8.1/scripts/setup.php: 3 Time(s) //phpMyAdmin-2.8.2/scripts/setup.php: 3 Time(s) //phpMyAdmin-2/scripts/setup.php: 4 Time(s) //phpMyAdmin/: 1 Time(s) //phpMyAdmin/scripts/setup.php: 8 Time(s) //phpadmin/scripts/setup.php: 6 Time(s) //phpm/scripts/setup.php: 2 Time(s) //phpmanager/scripts/setup.php: 5 Time(s) //phpmy-admin/scripts/setup.php: 5 Time(s) //phpmy/scripts/setup.php: 2 Time(s) //phpmya/scripts/setup.php: 2 Time(s) //phpmyad/scripts/setup.php: 2 Time(s) //phpmyadmin/: 1 Time(s) //phpmyadmin/scripts/setup.php: 4 Time(s) //phpmyadmin1/scripts/setup.php: 4 Time(s) //phpmyadmin2/scripts/setup.php: 3 Time(s) //pma/scripts/setup.php: 3 Time(s) //pma2005/scripts/setup.php: 1 Time(s) //scripts/setup.php: 4 Time(s) //sqlmanager/scripts/setup.php: 2 Time(s) //sqlweb/scripts/setup.php: 3 Time(s) //typo3/phpmyadmin/scripts/setup.php: 4 Time(s) //web/phpMyAdmin/scripts/setup.php: 4 Time(s) //web/scripts/setup.php: 4 Time(s) //webadmin/scripts/setup.php: 3 Time(s) //webdb/scripts/setup.php: 3 Time(s) //websql/scripts/setup.php: 5 Time(s) //xampp/phpmyadmin/scripts/setup.php: 4 Time(s) //~/PMA/scripts/setup.php: 2 Time(s) /MyAdmin/scripts/setup.php: 1 Time(s) /cp_errordocument.shtml: 1 Time(s) /index.php?option=com_community: 1 Time(s) /level/99/exec/show/config: 1 Time(s) /muieblackcat: 3 Time(s) /myadmin/scripts/setup.php: 1 Time(s) /phpMyAdmin/scripts/setup.php: 1 Time(s) /phpmyadmin/scripts/setup.php: 1 Time(s) /pma/scripts/setup.php: 1 Time(s) /robots.txt: 1 Time(s) /w00tw00t.at.blackhats.romanian.anti-sec:): 1 Time(s) /webdav/: 1 Time(s) /wp-login.php: 1 Time(s) ---------------------- httpd End -------------------------

こんなアクセスが毎日続くようじゃちょっと不安なので,とりあえずjpドメインとbbtec.net(Yahoo!BB)以外からのアクセスを禁止するためにapacheの設定「httpd.conf」を変更してみました.

.htaccessは制限をかけるフォルダ(例えば/var/www/html)に作成しますが,apacheのhttpd.confの中に設定があるのでこれを利用しました.

デフォルトのhttpd.confにあるAllowoverrideをAllにする必要があるんですが,Allowoverrideはの間に書きます.なので,今回は/var/www/htmlに対して.htaccessを設定するので,まずはrootになってhttpd.confを開きます.場所は/etc/httpd/conf/httpd.conf.

[root@localhost]# vim /etc/httpd/conf/httpd.conf

すると後半に次のようなものが見えてきます.

# # This should be changed to whatever you set DocumentRoot to. # # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.2/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None # # Controls who can get stuff from this server. # Order allow,deny Allow from all

ここを下にあるように変更します

# # This should be changed to whatever you set DocumentRoot to. # # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.2/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride All # # Controls who can get stuff from this server. # order deny,allow deny from all allow from .jp allow from .bbtec.net

に変更.変更箇所はAllowOverride Allと最後の4行.jpドメインとYahoo!BBのみがアクセスできるようにしています.vimで保存したら

service httpd restart

してapacheを再起動すればYahoo!BBとjpドメイン以外からのアクセスが禁止されました.

« ソフトバンクの「みまもりケータイ」シリーズの機能比較と「みまもりケータイ3」のSMSによる管理モードについて | トップページ | NHK総合テレビ「おはよう日本」内のコーナー番組「世界のニュースザッピング」2014年5月のまとめ »

パソコン・インターネット」カテゴリの記事

広告


  • Googe Adsense

Ad




  • ネットショップ

Googleで検索

2016年6月
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    

SNS

アクセス解析