Apache (Custom)


Apache is the most widely used web server software. Developed and maintained by Apache Software Foundation, Apache is an open source software available for free.

Integration of Apache on Ubuntu with DNIF Adapter

To forward Apache logs to the DNIF Adapter make the following configuration

Log in to the server that hosts Apache, as the root user.

Install syslog package, if you haven’t installed it

apt-get install rsyslog

Edit the Apache configuration file apache2.conf.

vim /etc/apache2/apache2.conf

Add the following information in the Apache configuration file to specify a DNIF custom log format:

LogFormat  "t:%t A:%A p:%p h:%h m:%m H:%H f:%f q:%q r:%r s:%s  ua:\"%{User-Agent}i\" ref:\"%{Referer}i\" fwd:%{X-Forwarded-For}i  host:%{Host}i B:%B D:%D k:%k l:%l u:%u U:%U v:%v V:%V X:%X I:%I  O:%O  T:%T uid:%{UNIQUE_ID}e" a2dnifcust

Now, edit ../sites-enabled/000-default.conf

vim /etc/apache2/sites-enabled/000-default.conf

And add following information to enable loging facility:

####For error logs
ErrorLog ${APACHE_LOG_DIR}/error.log
ErrorLog syslog:local1

####For access logs
CustomLog ${APACHE_LOG_DIR}/access.log combined
CustomLog "|/usr/bin/logger -t Apache -i -p local2.info" a2dnifcust

Save the Apache configuration file.

Edit the syslog configuration file.

vim /etc/rsyslog.d/50-default.conf

Add the following information to syslog configuration file:

##For System logs
*.*		@DNIF-Adapter-IP:514

##For apache logs
local1.*	@DNIF-Adapter-IP:514
local2.*	@DNIF-Adapter-IP:514

Save the syslog configuration file.

Restart the rsyslog service.

 /etc/init.d/rsyslog restart

Restart Apache to complete the syslog configuration.

 /etc/init.d/apache2 restart

Apache logs are now being streamed to the DNIF-ADAPTER.

Integration of Apache on CentOS-RHEL with DNIF Adapter

To forward Apache logs to the DNIF Adapter make the following configuration.

Log in to the server that hosts Apache, as the root user.

Install syslog package, if you haven’t installed it

yum -y install rsyslog

Edit the configuration file httpd.conf:

vim /etc/httpd/conf/httpd.conf

Add the following information in the http configuration file to specify a custom path for the syslog events:

####For error logs
ErrorLog logs/error_log
ErrorLog syslog:local1

####For access logs
CustomLog logs/access_log combined
CustomLog "|/usr/bin/logger -t httpd -p local2.info" combined

Save the Apache configuration file.

Edit the syslog configuration file:

vim /etc/rsyslog.conf

Add the following information to syslog configuration file:

##For System logs
*.*		@DNIF-Adapter-IP:514

##For apache logs
local1.*	@DNIF-Adapter-IP:514
local2.*	@DNIF-Adapter-IP:514

Save the syslog configuration file.

Restart the rsyslog service.

 /etc/init.d/rsyslog restart

Restart Apache to complete the syslog configuration.

 /etc/init.d/httpd restart

Apache logs are now being streamed to the DNIF-ADAPTER.