Proxylizer/Getting Started: Difference between revisions

From MikroTik Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
== Download ==
TODO
== Install ==
== Install ==


Line 24: Line 21:


===Proxylizer server===
===Proxylizer server===
All the exemples assume that web page root directory is "/var/www/proxylizer", webserver user is "www-data", Proxylizer server system user is "proxylizer" and .pipe file destination/name is "/home/proxylizer/mysql.pipe".
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".
==== Web page scripts ====
==== Web page scripts ====
TODO
TODO
Line 33: Line 30:
<pre> chown proxylizer:www-data /var/www/proxylizer -R </pre>
<pre> chown proxylizer:www-data /var/www/proxylizer -R </pre>


Set write permisions to web page root directory for webserver user
Set write permissions to web page root directory for web server user


<pre> chmod g+w /var/www/proxylizer </pre>
<pre> chmod g+w /var/www/proxylizer </pre>


Set permisions to execute 3 shell script files for webserver user group.
Set permissions to execute 3 shell script files for web server user group.
<pre>
<pre>
cd /var/www/proxylizer
cd /var/www/proxylizer
Line 63: Line 60:
Create pipe file.
Create pipe file.


<pre>mkfifo mysql.pipe</pre>
<pre>mkfifo /home/proxylizer/mysql.pipe</pre>
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 <pre>$MYSQL_PIPE = "/home/proxylizer/mysql.pipe";</pre>


restart syslog
restart syslog
Line 71: Line 69:
==== Web server with PHP and PHP-Pear ====
==== Web server with PHP and PHP-Pear ====


Install webserver (we recomend Apache2), PHP5, PHP5-cli and PHP-Pear : DB, Mail, Mail_Mime and Net_SMTP packages.
Install web server (we recommend Apache2), PHP5, PHP5-cli and PHP-Pear : DB, Mail, Mail_Mime and Net_SMTP packages.
<pre>apt-get install libapache2-mod-php5 php5-cli php-pear php-db php-mail php-mail-mime php-net-smtp</pre>
<pre>apt-get install libapache2-mod-php5 php5-cli php-pear php-db php-mail php-mail-mime php-net-smtp</pre>


==== MySQL database server ====
==== MySQL database server ====


Install MySQL datanbase server.
Install MySQL database server.
<pre> apt-get install mysql-server mysql-client </pre>
<pre> apt-get install mysql-server mysql-client </pre>


Line 95: Line 93:


==== Scheduled scripts for report generation ====
==== Scheduled scripts for report generation ====
TODO
 
   
<pre>
mkdir /var/log/proxylizer
chown proxylizer:proxylizer /var/log/proxylizer
chmod u+w /var/log/proxylizer
</pre>
 
Put two scripts in cron sheduler. First create crontab file for web server system user and copy these lines.
<pre>
nano /home/proxylizer/proxylizercrontab
 
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
* *    * * *          cd /var/www/proxylizer/ && ./mail_send.php >> /var/log/mail_send_log.log
* *    * * *          /var/www/proxylizer/checkwebproxy.sh >> /var/log/checkwebproxy.log &
</pre>
Set scheduler tasks from this file
<pre>crontab proxylizercrontab</pre>

Revision as of 09:22, 7 January 2009

Install

All the examples assume that Proxylizer server IP address is 10.1.1.2;

The installation includes steps for setting up the following:

  1. Web-proxy log export to remote host (Proxylizer server)
  1. Web page scripts
  2. Permissions for directories
  3. Syslog deamon
  4. Web server with PHP and PHP-Pear
  5. MySQL database server
  6. MySQL user created for proxylizer database
  7. Scripts/daemons forwarding records from syslog to MySQL
  8. Scheduled scripts for report generation

Mikrotik router

Web-proxy log export to remote host

TODO

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".

Web page scripts

TODO

Permissions for directories

Open console. 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

Install syslog-ng daemon.

apt-get install syslog-ng

WARNING : If you have Ubuntu OS syslog-ng can conflict with ubuntu-minimal package! You can remove this package.

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 {
#file("/var/log/proxy.log");
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

Web server with PHP and PHP-Pear

Install web server (we recommend Apache2), PHP5, PHP5-cli and PHP-Pear : DB, Mail, Mail_Mime and Net_SMTP packages.

apt-get install libapache2-mod-php5 php5-cli php-pear php-db php-mail php-mail-mime php-net-smtp

MySQL database server

Install MySQL database server.

 apt-get install mysql-server mysql-client 

MySQL user created 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;

Scripts/daemons forwarding records from syslog to MySQL

Start php script, that will read from mysql.pipe file, and insert records in database.

/var/www/proxylizer/webproxylogtomysql.php

Scheduled scripts for report generation

mkdir /var/log/proxylizer
chown proxylizer:proxylizer /var/log/proxylizer
chmod u+w /var/log/proxylizer

Put two scripts in cron sheduler. First create crontab file for web server system user and copy these lines.

nano /home/proxylizer/proxylizercrontab

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
* *     * * *           cd /var/www/proxylizer/ && ./mail_send.php >> /var/log/mail_send_log.log
* *     * * *           /var/www/proxylizer/checkwebproxy.sh >> /var/log/checkwebproxy.log &

Set scheduler tasks from this file

crontab proxylizercrontab