====== Закрытие доступа в ЛК из "мира" ======
===== Настройка httpd =====
В файле /etc/httpd/vhosts.d/stat_vhost.conf\\
Найдите блок:\\
AllowOverride All
Options FollowSymlinks Includes
Allow from all
И замените на:\\
AllowOverride All
Options FollowSymlinks Includes
Order Deny,Allow
Deny from all
# localhost
Allow from 127.0.0.1
# local net
Allow from 192.168.0.0/16
Allow from 172.16.0.0/12
Allow from 10.0.0.0/8
# trusted hosts
Добавив под **# trusted hosts** свои доверенные адреса, сохраняя синтаксис **Allow from**.
После чего перезапустите httpd выполнив:\\
/etc/init.d/httpd restart
===== Настройка nginx =====
Создадим файл для регулирования доступа:\\
nano /etc/nginx/access.list
Вставим туда подготовленный шаблон:\\
# localhost (для внутренних запросов)
allow 127.0.0.1;
# local net (локальные клиенты)
allow 192.168.0.0/16;
allow 172.16.0.0/12;
allow 10.0.0.0/8;
# trusted hosts
# deny others
deny all;
Под **trusted hosts** можете добавить свои IP адреса или сети которым нужно оставить доступ сохраняя синтаксис ( в начале **allow** а в конце **;** ).\\
\\
Редактируем виртуальный хост личного кабинета:\\
nano /etc/nginx/conf.d/stat_vhost.conf
находим блок:\\
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php-worker-socket;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/mikbill/stat/$fastcgi_script_name;
}
и добавляем в него **include access.list;**, что бы получилось:\\
location ~ \.php$ {
include access.list;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php-worker-socket;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/mikbill/stat/$fastcgi_script_name;
}
Перезагружаем nginx:\\
/etc/init.d/nginx restart
===== Замена файлов ЛК =====
Перейдем в нужную директорию:
cd /var/www/mikbill
Скачаем архив с обновленными файлами ЛК:
wget https://wiki.mikbill.ru/_media/billing/stat.tar.gz
Удалим старые файлы:
rm -f stat/main.php
rm -f stat/pay.php
rm -f stat/data/lib/gettext.inc
rm -f stat/data/lib/gettext.php
rm -f stat/data/lib/streams.php
rm -rf stat/res/paysystems/*
Распакуем {{:billing:stat.tar.gz|новые файлы}}:
tar xzf stat.tar.gz
Обновим права:
chown apache:apache -R stat/*
chmod 755 stat/pay.php
chmod 755 -R stat/res/paysystems/*.php
Выполним:\\
find /var/www/mikbill/stat/ -type f \( ! -name "*.php" -and ! -name "*.tpl" -and ! -name "*.txt" \) -exec grep -H '
Все найденные файлы нужно удалить.\\
\\
Готово.
===== iptables =====
Так же, **настоятельно** рекомендуем закрыть сервер через iptables.\\
# localhost
iptables -A INPUT -i lo -j ACCEPT
# related
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
# local net / trusted hosts
iptables -A INPUT -s 10.0.0.0/8 -j ACCEPT
iptables -A INPUT -s 172.16.0.0/12 -j ACCEPT
iptables -A INPUT -s 192.168.0.0/16 -j ACCEPT
# accept dhcp
iptables -A INPUT -p udp --dport 67 -j ACCEPT
# accept web
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 81 -j ACCEPT
iptables -A INPUT -p tcp --dport 82 -j ACCEPT
iptables -A INPUT -p tcp --dport 83 -j ACCEPT
iptables -A INPUT -p tcp --dport 84 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
# accept radius
iptables -A INPUT -p udp --dport 1812 -j ACCEPT
iptables -A INPUT -p udp --dport 1813 -j ACCEPT
# drop others
iptables -A INPUT -j DROP