NGINX


Nginx is a web server. It can act as a reverse proxy server for HTTP, HTTPS, SMTP, POP3, and IMAPprotocols, as well as a load balancer and an HTTP cache.

Integration of NGINX on Ubuntu with DNIF Adapter

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

Install syslog package, if you haven’t installed it

apt-get install rsyslog

Checking the rsyslog.conf

Open a rsyslog.conf file located at /etc/rsyslog.conf by following command

vim /etc/rsyslog.conf

At the end of the file check for the following line and uncomment

$IncludeConfig /etc/rsyslog.d/*.conf

# Include all config files in /etc/rsyslog.d/
$IncludeConfig /etc/rsyslog.d/*.conf

Save and Quit the configuration file.

Create log configuration for NGINX with vim /etc/rsyslog.d/nginxlog.conf and paste following lines below

$ModLoad imfile

# Nginx access file
$InputFileName /var/log/nginx/access.log  ##path of log file
$InputFileTag nginx-access:
$InputFileStateFile stat-nginx-access
$InputFileSeverity info
$InputFileFacility local1
$InputFilePersistStateInterval 20000
$InputRunFileMonitor

#Nginx Error file
$InputFileName /var/log/nginx/error.log  ##path of log file
$InputFileTag nginx-error:
$InputFileStateFile stat-nginx-error
$InputFileSeverity error
$InputFileFacility local1
$InputFilePersistStateInterval 20000
$InputRunFileMonitor

local1.*        @DNIF-Adapter-IP:514

Save and Quit the configuration file.

Restart rsyslog service

service rsyslog restart

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

Integration of NGINX on CentOS-RHEL with DNIF Adapter

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

Install syslog package, if you haven’t installed it

yum -y install rsyslog

Checking the rsyslog.conf

Open a rsyslog.conf file located at /etc/rsyslog.conf by following command

vim /etc/rsyslog.conf

At the end of the file check for the following line and uncomment

$IncludeConfig /etc/rsyslog.d/*.conf

# Include all config files in /etc/rsyslog.d/
$IncludeConfig /etc/rsyslog.d/*.conf

Save and Quit the configuration file.

Create log configuration for NGINX with vim /etc/rsyslog.d/nginxlog.conf and paste following lines below

$ModLoad imfile

# Nginx access file
$InputFileName /var/log/nginx/access.log  ##path of log file
$InputFileTag nginx-access:
$InputFileStateFile stat-nginx-access
$InputFileSeverity info
$InputFileFacility local1
$InputFilePersistStateInterval 20000
$InputRunFileMonitor

#Nginx Error file
$InputFileName /var/log/nginx/error.log  ##path of log file
$InputFileTag nginx-error:
$InputFileStateFile stat-nginx-error
$InputFileSeverity error
$InputFileFacility local1
$InputFilePersistStateInterval 20000
$InputRunFileMonitor

$WorkDirectory /var/lib/rsyslog
$ActionQueueFileName fwdRule1 # unique name prefix for spool files
$ActionQueueMaxDiskSpace 1g   # 1gb space limit (use as much as possible)
$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
$ActionQueueType LinkedList   # run asynchronously
$ActionResumeRetryCount -1

local1.*        @DNIF-Adapter-IP:514

Save and Quit the configuration file.

Restart rsyslog service

service rsyslog restart

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