Proxylizer/Getting Started
Download
You can download proxylizer archive here.
Install
All the examples assume that Proxylizer server IP address is 10.1.1.2 and syslog-ng uses port 514 that is its default
The installation includes steps for setting up the following:
Mikrotik router
Web-proxy log export to remote host (Proxylizer server)
To forward logs from Mikrotik Router to Proxylizer server, open RouterOS console and type in the following commands:
/system logging action add name=sendToProxylizer target=remote remote=10.1.1.2:514 /system logging add topics=web-proxy action=sendToProxylizer
Note that logs are sent to port number 514, it must be equal with the port on which Syslog daemon on Proxylizer server is listening.
Proxylizer server
All the examples assume that web page root directory is "/var/www/proxylizer", web server user is "www-data", Proxylizer server system user is "proxylizer" and .pipe file destination/name is "/home/proxylizer/mysql.pipe".
Required packages
For Ubuntu issue this command to install all required packages:
sudo apt-get install syslog-ng libapache2-mod-php5 php5-cli php-pear php-db php-mail php-mail-mime php-net-smtp mysql-server mysql-client
WARNING : If you have Ubuntu syslog-ng can conflict with ubuntu-minimal package! You can remove this package.
Web page scripts
Download proxylizer archive. Create directory and extract it in web page root directory:
sudo mkdir /var/www/proxylizer/ sudo tar -xvzf /var/www/proxylizer/
Permissions for directories
Change ownership of web page root directory for web server user:
chown proxylizer:www-data /var/www/proxylizer -R
Set write permissions to web page root directory for web server user:
chmod g+w /var/www/proxylizer
Set permissions to execute 3 shell script files for web server user group:
cd /var/www/proxylizer chmod g+x checkwebproxy.sh mail_send.php webproxylogtomysql.php
Syslog daemon
Change syslog-ng config to receive logs from Mikrotik router and put them into mysql.pipe file. Open /etc/syslog-ng/syslog-ng.conf and add these lines next to "#destinations" :
destination d_mysql { pipe("/home/proxylizer/mysql.pipe" template("$HOST $YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC $MSG\n") template-escape(yes)); }; log { source(net); destination(d_mysql); };
And this line next to "#sources":
source net { udp(); }
Create pipe file:
mkfifo /home/proxylizer/mysql.pipe
Set destination of .pipe file in /var/www/proxylizer/webproxylogtomysql.php. At the beginning of the file you must change variable value in the line:
$MYSQL_PIPE = "/home/proxylizer/mysql.pipe";
restart syslog:
/etc/init.d/syslog-ng restart
MySQL user for proxylizer database
Default user name for mysql database is root with no password. But we recomend to change it for security reasons.
Connect to mysql server and create new database and user:
mysql -u root CREATE DATABASE proxylizerdb; GRANT ALL PRIVILEGES ON proxylizerdb.* TO proxylizer@localhost IDENTIFIED BY "password" WITH GRANT OPTION; FLUSH PRIVILEGES;
Scheduled scripts for forwarding records from syslog to MySQL and report generation
Create directory for script logs and set permesions:
mkdir /var/log/proxylizer chown proxylizer:proxylizer /var/log/proxylizer chmod u+w /var/log/proxylizer
If you want to write logs in different directory you must edit bash script "checkwebproxy.sh" and change "/var/log/proxylizer" to preferred directory.
Put two scripts in cron sheduler. First create crontab file for web server system user:
nano /home/proxylizer/proxylizercrontab
and copy these lines:
SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin * * * * * /var/www/proxylizer/mail_send.php >> /var/log/proxylizer/mail_send_log.log * * * * * /var/www/proxylizer/checkwebproxy.sh >> /var/log/proxylizer/checkwebproxy.log &
Set scheduler tasks from this file:
crontab /home/proxylizer/proxylizercrontab
Database and web page access configuration
When all previous settings is set. Open web browser and point it to proxylizer server. First page must be like this :
- DB type - for now Proxylizer supports only MySQL, in future PostgreSQL, Interbase and other data bases will be added;
- DB host - if data base on the same computer then localhost;
- DB name - if settings from example then "proxylizer";
- DB username and password - as you hawe set here;
- Webpage username an password - as you prefer;
Setup page is shown always when the config file config_constants.php
is not found in the Proxylizer root directory. On successful setup the configuration is written to this file. Configuration file contains database access and web page access parameters, no report or IP user configuration is included.