Nginx and Apache integration on Plesk

Community support for Plesk, CPanel, WebMin and others with insight from two of the founders of Plesk. Ask for help here! No question is too simple or complicated. :-)
carlswart
Forum User
Forum User
Posts: 20
Joined: Sun Dec 19, 2004 2:41 am
Location: South Africa

Nginx and Apache integration on Plesk

Unread post by carlswart »

Goal: To integrate Nginx seamlessly on a server running Plesk 8.3 or later

What have been done?
Nginx has been configured and installed and has been setup in a way that minimises the changes to the Plesk setup.

The changes were limited to the following:

1. Updating the

Code: Select all

httpd.conf
file to listen on only certain IP addresses.

2. Adding the

Code: Select all

rpaf.conf
file to

Code: Select all

/etc/http/conf.d
to enable mod_rpaf.

3. Adding a line to the

Code: Select all

vhost.conf
file of the affected site.

Nginx was then configured to serve all requests for the site and to proxy any dynamic (PHP) requests to Apache.

Nginx now logs all the requests to the site's default log directory, created and maintained by Plesk.

What needs to be done?
For the integration to be seamless, I need Plesk to process the Nginx log files instead of the Apache log files.

Apache creates:

Code: Select all

/statistics/logs/access_log
/statistics/logs/error_log
Nginx creates:

Code: Select all

/statistics/logs/nginx_access_log
/statistics/logs/nginx_error_log
Plesk processes all the log files by running the statistics (/usr/local/psa/admin/sbin/statistics) script once a day.

The one possible solution that I could come up with is for me to write a wrapper script, that would execute and:

1. Move

Code: Select all

nginx_access_log
to

Code: Select all

access_log
(ie. replace it)

2. Merge

Code: Select all

error_log
with

Code: Select all

nginx_error_log
, using

Code: Select all

logresolvemerge.pl
3. Reload Nginx and Apache to force them to open new log files.

4. Apache would then start logging to the old

Code: Select all

nginx_access_log
(now

Code: Select all

access_log
) and the merged

Code: Select all

error_log
5. The final step would be to call statistics.

The statistics script would then run like normal, like it always was, processing the following files:

Code: Select all

access_log
error_log
The above process, should allow Plesk to continue reporting on the all the normal traffic accounting.

Where do you fit in?
I was hoping that you may have a bit more in-depth knowledge of the statistics script's inner workings.

Perhaps if I named the files in a certain way, statistics would pickup all the log files and process them?

Any input in this regard, to try and make the integration just that little bit more elegant, would be great.
Post Reply