Commit 8c4066f3 authored by Vitaly Lipatov's avatar Vitaly Lipatov

spec: add ban-internal-server subpackage

parent a3f8fe16
//Где сменить IP-адреса серверов
<?php
$ip = $_SERVER['REMOTE_ADDR'];
echo "You are banned!, Your IP: $ip <br>";
$settings = '/etc/eterban/settings.ini';
$ini_array = parse_ini_file ("$settings");
$host_redis = $ini_array['redis_server'];
$redis = new Redis;
$redis->pconnect ($host_redis,6379);
$key = $redis->get($ip);
?>
<button onclick="unban()">Unban</button>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.js"></script>
<script>
function unban(){
/*$.get("unban.php?&key=<?php echo $key;?>", function(data, status){
});*/
window.location.href = "unban.php?key=<?php echo $key; ?>";
}
</script>
\ No newline at end of file
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>IP-адрес, к которому вы обратились, заблокирован на сервере. This IP is banned!</title>
<style>
html {
font-family: sans-serif;
text-align: center;
}
body {
overflow: hidden;
}
big {
font-weight: bold;
}
.center {
width: 800px;
height: 500px;
max-width: 100vw;
max-width: calc(100vw - 2rem);
min-height: 100vh;
margin: auto;
display: flex;
justify-content: center;
align-items: center;
}
.button {
text-decoration: none;
display: inline-block;
width: 140px;
height: 40px;
line-height: 40px;
border-radius: 5px;
margin: 10px 20px;
font-family: inherit;
font-size: 15px;
text-transform;
text-align: center;
font-weight: 600;
color: #ffffff;
background: #0d6efd;
box-shadow: 0 8px 15px rgba(0, 0, 0, .1);
transition: .3s;
}
.button:hover {
background: #2EE59D;
box-shadow: 0 15px 20px rgba(46, 229, 157, .4);
color: white;
transform: translateY(-7px);
}
</style>
</head>
<body>
<div class=center>
<p><big>Доступ к запрашиваемому ресурсу ограничен в связи с подозрительной активностью этого IP-адреса. <br>
Если вы считаете, что блокировка ошибочна, обратитесь к администратору.<br>
<br> Access to the requested resource is restricted due to suspicious activity from this IP address. <br>
If you believe this is a mistake, please contact your administrator.</big>
</div>
</body>
<html>
YYYYYYYYYYYYYes
\ No newline at end of file
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$old_addr = $_SERVER['HTTP_REFERER'];
$settings = '/etc/eterban/settings.ini';
$ini_array = parse_ini_file ("$settings");
//print_r($ini_array);
//print_r($ini_array['redis_server']);
$host_redis = $ini_array['redis_server'];
//print_r($host_redis);
$hostname = $ini_array['hostname'];
if (empty($hostname)) {
$hostname=gethostname();
//print_r ($hostname);
}
$redis = new Redis();
$redis->pconnect($host_redis,6379);
$redis->publish('unban', $ip);
$redis->publish('by', $ip . " was unblocked by $hostname");
$redis->close();
echo "Wait 5 seconds, please"
?>
<script>
function update()
{
window.location.href = "/";
}
setTimeout("update()", 5000);
</script>
server {
listen 91.232.225.67:82;
#server_name priv.etersoft.ru;
root /var/www/html/eterban-internal/;
location / {
# add_header Access-Control-Allow-Origin *;
# try_files $uri $uri/ /index.php?$query_string;
index index.html;
#include /etc/nginx/fastcgi_params;
#fastcgi_pass unix:/var/run/php7-fpm/php7.fpm.sock;
}
location ~* \.php$ {
#try_files $uri = 404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php7-fpm/php7-fpm.sock; # подключаем сокет php-fpm
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
access_log /var/log/nginx/eterban_access.log;
error_log /var/log/nginx/eterban_error.log;
}
......@@ -88,6 +88,11 @@ install -m 644 gateway/etc/cron.hourly/* %buildroot/etc/cron.hourly/
install -m 644 ban-server/data/www/* %buildroot%webserver_htdocsdir/%name/
install -m 644 ban-server/etc/nginx/sites-enabled.d/* %buildroot/etc/nginx/sites-enabled.d/
mkdir -p %buildroot%webserver_htdocsdir/%name-internal/
mkdir -p %buildroot/etc/nginx/sites-available.d/
install -m 644 ban-internal-server/data/www/* %buildroot%webserver_htdocsdir/%name-internal/
install -m 644 ban-internal-server/etc/nginx/sites-enabled.d/eterban.conf %buildroot/etc/nginx/sites-available.d/eterban-internal.conf
install -m 644 prod-server/etc/fail2ban/action.d/* %buildroot/etc/fail2ban/action.d/
cp -a prod-server/usr/share/%name/* %buildroot%_datadir/%name/
......@@ -116,7 +121,9 @@ cp -a prod-server/usr/share/%name/* %buildroot%_datadir/%name/
%files web
%webserver_htdocsdir/%name/
%webserver_htdocsdir/%name-internal/
%config(noreplace) /etc/nginx/sites-enabled.d/eterban.conf
%config(noreplace) /etc/nginx/sites-available.d/eterban-internal.conf
%files fail2ban
%_datadir/%name/ban.py
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment