# General questions
- How do I ban certain IPs on the server level?
- What changes can I make to the server configuration?
- Cases when you should not reboot your VPS/VDS server
- How to open a new port on the server
- How do I clear statistics and free up server space?
- How to free inodes usage?
- How to see the admin visiting history
- VPS works slowly
- How long are the postback logs kept? Where can I change the period for which the postback logs are kept?
- How to establish an FTP connection to a server after the installation
- How to setup emails sending
- How to delete a domain from the server
- How to set up the server after RAM or vCPU upgrade
- How do I check if my disk is HDD or SSD?
# How do I ban certain IPs on the server level?
You can change server settings in the local Nginx configuration files
/etc/nginx/conf.d/local. For changes on the server level, it's best to use
To block IPs this way, add:
deny x.x.x.x; allow all; When accessing a server through a terminal, use the
echo 'allow 22.214.171.124; deny all;' > /etc/nginx/conf.d/local/keitaro/admin.inc
command to forbid accessing admin page to anyone with the IP that is not 126.96.36.199 or the
echo 'allow 188.8.131.52; deny all;' > /etc/nginx/conf.d/local/keitaro/server.inc
command to forbid it on the server level. Accessing the admin page will only be possible with the IP 184.108.40.206 after that.
# What changes can I make to the server configuration?
With the right programming skills, you can use Nginx configuration files in
/etc/nginx/conf.d/local to change local configuration settings.
After the tracker has been installed, a new subdirectory will be created in this directory. It will contain:
server.inc- you can make changes for the whole server here.
admin.inc- you can use this for additional admin page settings, such as banning access from certain IPs.
tracker.inc- you can add additional ways to behave for the tracker's files and scripts (for example, to set up caching for the static websites).
nontracker.inc- you can add additional ways to behave for the files and scripts not directly connected to the tracker (for example, to set up caching for the static websites).
realip.inc- if your server is using a proxy (e.g. Cloudflare) and you need user IPs to be logged correctly in the nginx logs, you will need to add directives like ''set_real_ip_from a.b.c.d/x;''to this file (''a.b.c.d/x'' stands for the proxy IP network).
- for each separate domain, a new file is created here:
/etc/nginx/conf.d/local/domain.com.inc, which you can use to set behavior on the domain level.
E.g. if you need to ban bot traffic to all websites and the tracker admin panel, it's best to do it in
/etc/nginx/conf.d/local/keitaro/server.inc, or by changing separate domains' configuration.
Important to note! You will need to check the configs after each change is made with the command:
and only after that reload Nginx:
systemctl reload nginx
The full directories list is located here
# Cases when you should not reboot your VPS/VDS server
Sometimes there could be issues (due to high load, server error, DDoS & etc.) when the performance of the server is degrading, and the tracker itself works slowly - in such cases, it seems a good idea to reboot your server. But if the tracker is processing DB data or works with the statistical data of your tracker - we do not recommend you to perform rebooting, since you are risking to damage the database of the tracker, which leads to the data loss. The typical list of cases, where you should not reboot the server:
RedisException: OOM command not allowed when used memory > maxmemory- if Redis service is stopped or not working, but statistical data of campaign clicks are not being stuck in a queue of Redis service. Rebooting the server in such a case could lead to a loss of clicks from your visitors, which will not reach the tracker database. If the queue of command is constantly increasing, then we suggest contacting our technical support.
Deleting statistics- the query for optimization of your DB should work until it's done, in other cases - if you reboot the server while cleaning is going, you would need to start it over.
Optimization of database- in any case, we strictly do not recommend rebooting the server, while DB optimization is in progress. There is a high probability, that table (in which optimization was going on where the server was rebooted) - will be crashed, and DB itself will be locked until optimization will be performed, or in other cases - it will be recovering to its initial state (before starting optimization).
SSD issue or malfunctioning- in such a case, it is better to contact the technical support of your VPS/VDS server.
Kernel critical error- activation and creation of backups of your tracker should be your first priority in such a case. Make sure to back up the damp of DB, an archive of landing files, and etc.
No free space left on SSD- if server or SSD, will be overfilled and there will be no free space (you could check it using df -h command) - your VPS server will be not able to write data on your SSD since no free space left. The server would not start in such a case, because it needs at least 2-5 % of free space to make write/read operations. You can contact us, and we will seek which files could be cleaned or deleted.
# How to open a new port on the server
Use this command to open a port:
firewall-cmd --permanent --add-port=port_number/tcp
E.g., to open port 80:
firewall-cmd --permanent --add-port=80/tcp
And to add a range of ports:
firewall-cmd --permanent --add-port=6500-6700/udp
To add several ports with one command (here for port 80 & port 443):
firewall-cmd --permanent --add-port=80/tcp --add-port=443/tcp
# How do I clear statistics and free up server space?
The simplest way is to call for statistics to be cleared from the admin panel. You can do it in the 'Maintenance - Delete stats' menu.
To make sure your DB doesn't grow uncontrollably and the clicks are deleted automatically, you can set the default period after which they will be deleted. This can be done in Maintenance - Settings - System (Stats store term and Store resources in archive)
If your DB is getting overloaded and the free space on the disk is quickly running out, you can try these urgent methods:
- Clear all Redis' dumps through the terminal (this will delete all non-processed statistics!):
rm -r /var/lib/redis/*
- Delete stats up to a certain date. Note that it may take a long time if there is a high number of clicks in the DB.
export DB_NAME='keitaro' export DB_USER='root' mysql -u $DB_USER -e 'DELETE FROM keitaro_clicks WHERE datetime < "2018-01-01" ' $DB_NAME
- This command will help optimize the clicks table lowering the DB volume.
Note that this will lock the DB while it's being performed and requires extra free space on the disk.
cd /var/www/keitaro && sudo -u keitaro php bin/cli.php system:optimize_db
If shutting the server down is not an option, you can use Percona-toolkit for optimizing tables.
yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
yum install percona-toolkit
Please make sure there's enough free space on your server for optimization purposes. You will need free space equal to the volume of the DB itself or equal to the table in which the optimization is performed.
To start optimization with the use of Percona-toolkit, use:
pt-online-schema-change --alter='ENGINE=TokuDB' D=keitaro,t=keitaro_clicks --execute
- Use this command to clear all statistics and free up the disk space:
cd /var/www/keitaro && sudo -u keitaro php bin/cli.php system:delete_all_stats
After typing it in you will get the following warning:
[WARNING] Important! The following will happen: - old versions tables removal, - clicks stats to the exact date removal (if specified in parameters), - optimization of the clicks in the stats, - cleaning all the current stats completely (if specified in parameters). These inquiries will block the database during the implementation and require additional free space on a disk.
yes/no to confirm/cancel.
If confirmed, all statistics will be cleared.
- If you're upgrading from the Keitaro v.7, you can delete old tables through the terminal:
export DB_NAME='keitaro' export DB_USER='root' mysql -u $DB_USER -e 'show tables' $DB_NAME | grep -e 'keitaro_archive\|keitaro_index' | xargs -I "@@" mysql -u $DB_USER -e "TRUNCATE table \`@@\`" $DB_NAME
# How to free inodes usage?
If your tracker started to work incorrectly, and you are seeing messages about low disk space (while df -h showing you that you have enough disk space) - in such case, it may be, that inodes usage on your server is close to its capacity. Inodes - are file descriptors in Linux, which store the attributes and disk block locations of the object's data. File-system object attributes may include metadata (times of last change, access, modification), as well as owner and permission data. When the number of inodes is close to 0 - that means your OS is insufficient of file descriptors (inodes) In such a case, you need to delete those files. For searching inodes, you need to use the following command:
We will receive the output of the structure of your file system with a list of inodes number directly. Now you need to follow the directory with the biggest number of inodes in your system - you need to go in a directory with the biggest inodes number and look for the folder with the biggest inodes number. Finally, you will find the folder with the biggest inode count number. After that - you will need to delete this folder with the following command:
rm -rf deletedfolder/
Where deletedfolder/ is the name of the folder with the biggest inode number which you need to delete. WARNING Please verify the folder which you are going to delete - your target is to delete the folder with most of the files descriptors (or biggest inode number) BUT not system files of your OS or a server. If you are not sure what are you doing - it is better to refer to our technical support which will help you gladly to free inodes usage on your server. In other cases, you are risking to make your server unworkable.
# How to see the admin visiting history
The access log is saved in
/var/log/nginx/admin.access.log. You can check the log with the terminal the following way:
Or request the last logins:
tail -n 100 /var/log/nginx/admin.access.log
# VPS works slowly
This could happen because of the lack of CPU resources for your virtual server. Run the command:
vmstat 1 5
As a result you’ll see the following table:
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 111 0 0 3438984 20280 603200 0 0 11 20 38 85 10 2 32 0 56 139 0 0 3435676 20280 603220 0 0 0 0 936 318 15 3 0 0 82 126 0 0 3434312 20280 603212 0 0 0 0 903 198 14 4 0 0 82 92 0 0 3450964 20280 603868 0 0 0 0 885 198 13 3 0 0 83 145 1 0 3452128 20280 604412 0 0 448 0 993 254 14 2 0 0 84
Pay attention to the last column
st. If the value is more than 0 – your VPS has insufficient resources. Contact your server provider in this case.
# How long are the postback logs kept? Where can I change the period for which the postback logs are kept?
The log's size limit is stated here
# How to establish an FTP connection to a server after the installation
# How to setup emails sending
There's no special email service on a server, all emails should be sent with the external service. For 100-150 emails daily use Gmail.
# How to delete a domain from the server
To delete the domain and its certificate from the web server run the command:
curl https://raw.githubusercontent.com/apliteni/centos_provision/current/scripts/delete-ssl.sh > delete-ssl; bash delete-ssl domain.com
domain.com with your domain's name.
# How to set up the server after RAM or vCPU upgrade
Run the upgrade.
The upgrade will erase all custom nginx configs and rewrite them with the default values.
# How do I check if my disk is HDD or SSD?
Check the disks' names here: