最近公司內(nèi)部為了外部訪問(wèn)方便搭建了一臺(tái)堡壘機(jī),然后發(fā)現(xiàn)老是被字典破解,后臺(tái)登錄記錄全是弱密碼暴力破解

暴力破解記錄
雖然我的用戶名密碼比較安全,但也是虛的一逼啊,抓緊時(shí)間禁止它訪問(wèn).雖然國(guó)內(nèi)也會(huì)有肉雞攻擊,但畢竟減少了不少概率.
- 先查看下nginx是否編輯有GeoIP模塊:
nginx -V在輸出界面看是否有--with-http_geoip_module
若沒(méi)有yum -y install geoip-develGeoIP數(shù)據(jù)庫(kù)會(huì)被安裝在/usr/share/GeoIP/GeoIP.dat
也可以從 http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz 這里下載最新的GeoIP數(shù)據(jù)庫(kù)文件。
[root@zk conf.d]# nginx -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --省略一部分-- --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module -m64--省略一部分--'
然后開(kāi)始配置nginx的配置文件/etc/nginx/nginx.conf, 我配置的只允許中國(guó)訪問(wèn):
# 訪問(wèn)地理位置限制,這里只允許中國(guó)ip訪問(wèn),降低使用國(guó)外代理進(jìn)行暴力破解的概率--秦飛
geoip_country /usr/share/GeoIP/GeoIP.dat;
# geoip_city /usr/share/GeoIP/GeoLiteCity.dat;
# 下面一行根據(jù)實(shí)際情況編寫
map $geoip_country_code $allowed_country {
default no;
CN yes;
}
然后在server塊里面進(jìn)行配置:
server {
listen 80; # 代理端口,以后將通過(guò)此端口進(jìn)行訪問(wèn),不再通過(guò)8080端口
server_name xx.xx.xx; # 修改成你的域名或者注釋掉
client_max_body_size 100m; # 錄像及文件上傳大小限制
if ($allowed_country = no) {
return 403;
}
----------------略略略一大堆東西-----------------
}
如果國(guó)家訪問(wèn)規(guī)則的匹配結(jié)果是no,則返回403

瀏覽器訪問(wèn)結(jié)果
至此基于國(guó)家的訪問(wèn)控制完成.
只允許域名訪問(wèn)基于端口:
server{
listen 80 default_server;
server_name _;
return 403;
}
每一個(gè)端口在此配置一個(gè)server塊, 接收ip請(qǐng)求返回403即可
參考資料:
https://blog.csdn.net/linux_newbie_rookie/article/details/78663721
https://takeshiyako.blogspot.com/2016/10/nginx-ngx-http-geoip-module.html
https://docs.nginx.com/nginx/admin-guide/security-controls/controlling-access-by-geoip/