General

Setup nginx_apache reverse proxy

With the nginx_apache reverse proxy, static files are served by Nginx and PHP files are processed by Apache, thus overall performance is improved.

And yes, the setup is fully compatible with .htaccess files.

In general, the schema is:

  1. A new connection arrives and Nginx handles it. If it is for a static file (not a PHP script), go to step 2, else go to step 3.
  2. Nginx serves the static file to the user.
  3. Nginx forwards the file to Apache. Go to 4.
  4. Apache handles the PHP request - it tells PHP-FPM to compile it (if it is in FPM mode). Go to 5.
  5. Apache returns the output of the script to Nginx. Go to 6.
  6. Nginx returns the file back to the user.

To install nginx_apache, do the following:

cd /usr/local/directadmin/custombuild
./build set webserver nginx_apache
./build nginx_apache
./build rewrite_confs

As Nginx and Apache are working simultaneously, if any modifications are necessary (such as the creation of a wildcard subdomain, automatic Webmail subdomains, etc), you must apply the necessary edits to both Nginx and Apache. Use appropriate sections in this guide for instructions.

Last Updated: