Getting Started

By default, DirectAdmin uses the Apache webserver to serve websites. Apache currently reigns as the best server for websites. The reasons for apache server’s popularity is well documented. Apache’s power and the ability to serve Perl and Python. However, Apache servers carries some drawbacks. Apache contains high memory footage. Nginx is another powerful open source web server that is faster and consumes less RAM.

WeKNow DirectAdmin

Nginx does not have the ability to process dynamic content natively. To handle PHP and other requests for dynamic content, Nginx must pass the request to an external processor for execution and wait for the content to be sent back which can then be relayed to the client.

Benefits of an Nginx Reverse Proxy

There are a few benefits to setting up an Nginx reverse proxy. Although not required in all cases, it can be beneficial depending upon your particular scenario / setup. The following outlines a few benefits implementing a reverse proxy.

  • Load Balancing – A reverse proxy can perform load balancing which helps distribute client requests evenly across backend servers. This process greatly helps in avoiding the scenario where a particular server becomes overloaded due to a sudden spike in requests. Load balancing also improves redundancy as if one server goes down, the reverse proxy will simply reroute requests to a different server.
  • Increased Security – A reverse proxy also acts as a line of defense for your backend servers. Configuring a reverse proxy ensures that the identity of your backend servers remains unknown. This can greatly help in protecting your servers from attacks such as DDoS for example.
  • Better Performance – Nginx has been known to perform better in delivering static content over Apache. Therefore with an Nginx reverse proxy, all client requests can be handled by Nginx while all requests for dynamic content can be passed on to the backend Apache server. This helps improve performance by optimizing the delivery of assets based on their type. Additionally, reverse proxies can also be used to serve cached content and perform SSL encryption to take a load off the web server(s).
  • Easy Logging and Auditing – Since there is only one single point of access when a reverse proxy is implemented, this makes logging and auditing much simpler. Using this method, you can easily monitor what goes in and out through the reverse proxy.

Installation Steps

For installation, we need access to the server and all root privileges for changing the configurations on the server.

First of all make sure you have custombuild 2 installed:
cd /usr/local/directadmin/custombuild
./build version

build Nginx + Apache

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

If you experience any problem, you can always revert back with
cd /usr/local/directadmin/custombuild
./build update
./build update_da
./build set webserver apache
./build apache
./build rewrite_confs

Nginx Reverse Proxy – Summary

There are various use cases where setting up a reverse proxy may come in handy. Although not required in all situations, it can prove to be quite effective in boosting performance and enhancing security. The configuration required for setting up a basic Nginx reverse proxy is quite simple. Although there are various other directives available depending upon your requirements, the above example should help in quickly getting started with a reverse proxy setup.


This article was written by: Alentejo Hosting.

Was this article helpful to you?

Leave a Reply