engine x) is a small robust HTTP and reverse proxy server, as well as a mail proxy server written by Igor Sysoev. It has been running for more than five years on many heavily loaded Russian sites including Rambler.
Nginx is available at http://nginx.org/en/download.html
We all know our beloved and revered Web server Apache. Unfortunately the time it made so much “featured”, which sometimes struck by how much memory and resources in general, he can eat on a fairly simple tasks. And sometimes the server simply can not cope with the load (basically not enough memory).
It is necessary to note the fact - Apache completely wasteful spending in the memory of the impact of static content (images, HTML files, styles, etc. - any content that does not contain a server-side code).
Fortunately there is something to compare. It has long appeared an easy web server Nginx. It was written originally optimized for static and impact, in comparison with Apache, totally consumes memory. And wherever they can temporarily throw off a chunk of memory to disk, it does not leave extra system resources.
But Nginx does not contain any modules for the processing of dynamic content (except SSI). He can only “proxy” (pass) processing of content “backend” - gathered on the background dynamics processor Apache (or any other Web server). Just Nginx is able to communicate with Fast-CGI server on the backend.
This is where the separation begins at FrontEnd and BackEnd impact. The meaning is very simple - we give each do only what he's really good to do and nothing more. Nginx is on the front and accepts requests from clients. Inquiries as to the dynamic (or potentially dynamic content), Nginx proxy in backend, which presumably is Apache, and handles requests for dynamic content (eg, PHP-scripts). The result is given back to Nginx, which in turn returns the response to customers.
Thus, it is said, can “facilitate the Apache”, ie existing Apache put the backend, and before him on the front put Nginx. It is usually transferred to listen to what Apache is a port on 127.0.0.1 and there proxy send inquiries Nginx.
Unfortunately DirectAdmin checks for Apache on port 80 of the main IP, and change is impossible. According to this the only option, which will run this ligament is to install Nginx on other than port 80 (eg, 85) and forwarding all requests to port 80 (HTTP) on port 85. This can be done with FireWall.
To work properly need to make some changes in the work of DirectAdmin, which is recommended to do only experienced professionals.
Since the creation of Nginx configuration files necessary for each host, you must create a number of scripts, intercepting the following:
All of these scripts must be placed in the directory
/usr/local/directadmin/scripts/custom and have the right to perform system user
As seen from the content they interact with two scripts:
In turn, /usr/local/directadmin/scripts/nginx_task.sh must complete cron every 2 minutes what can be done by adding a line to crontab:
* / 2 * * * * root /usr/local/directadmin/scripts/nginx_task.sh
Such complexity is due to the fact that such tasks can be time consuming and lead to time-out Web Interface.
As seen from the contents, there are variables in the script of which we are interested in three:
This configuration file may not be sufficiently optimal for your case.
Please, enable mod_rpaf for Apache. Connect it like this:
LoadModule rpaf_module / usr/lib/apache/mod_rpaf-2.0.so RPAFenable On RPAFsethostname On RPAFproxy_ips **IP** RPAFheader X-Real-IP
Warning This statement implies that Nginx is installed in /usr/local/nginx. If not, then change the path for the correct scripts.