Introduction

Danginx is an Nginx integration plugin for Directadmin servers for increasing server speed , performance and protection.

How Nginx will help your Directadmin server to increase the performance ?


Nginx is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.
Unlike traditional servers, Nginx doesn’t rely on threads to handle requests. Instead it uses a much more scalable event-driven (asynchronous) architecture. This architecture uses small, but more importantly, predictable amounts of memory under load.
Even if you don’t expect to handle thousands of simultaneous requests, you can still benefit from Nginx’s high-performance and small memory footprint. Nginx scales in all directions: from the smallest VPS all the way up to clusters of servers.

Requirements

You need a Directadmin server running latest stable release of Directadmin with apache version 2.2. (If you are using freeBSD, this plugin is not tested for it).You need the following server requirements.

  • Linux Directadmin server latest stable version
  • Either php-curl or allow_url_fopen enabled in php
  • Ioncube enabled in php
  • PHP version 5 or later
  • Apache version 2.2 or later
  • Suhosin disabled
  • safe_mod= Off
  • The above changes are only required for installation time. You can revert the php.ini changes after the installation.

    Install Directadmin Nginx

    Download the latest danginx from https://syslintportal.com/downloads.php You may need to login to this portal before downloading.
    The file will be in a gtar format with a name like danginx.X.Y.tar.gz , where X.Y is the version . Now upload this to your server and install it as follows:

    # tar -xzf danginx.X.Y
    
    # cd danginx/
    
    # sh install.sh

    Now the installation has been completed. If you are upgrading from a lower version below 4.0 , please make sure to upgrade the license to new version before installing it. You can simply open a support ticket from your client area for upgrading your licenses. It is free.

    Configure DaNginx

    Danginx came with all the required default configurations . There is no need to configure it further more. But you can add custome settings.

    Uninstall DaNginx

    To remove the DaNginx Plugin execute the script as follows:

    # sh /etc/danginx/uninstall.sh

    Add custom file extensions to Nginx server

    To add a custom static file extension to nginx server edit the file /etc/danginx/fileextensions.txt then rebuild nginx vhost and restart it

    How to disable/enable nginx temporarily

    To disable nginx run the script:

    /usr/local/directadmin/scripts/disablenginx

    This will disable nginx server and switch apache to port 80.
    To enable a disabled nginx server run the script:

    /usr/local/directadmin/scripts/enablenginx

    This will enable nginx on port 80

    Direct Push

    This option will allow some domains/subdomain to directly pass to apache via nginx. So nginx won’t server any static files of that domain . To manage direct push use the command “”/usr/local/directadmin / scripts/directpush”“
    eg : To add a domain fun.com to direct push use /usr/local/directadmin/scripts/directpush add foo.com
    eg: To remove a domain fun.com from direct push use /usr/local/directadmin/scripts/directpush del foo.com
    eg : To list all direct pushed domains use /usr/local/directadmin/scripts/directpush list

    How to set custom expire time

    You can add custom expire time for domain/subdomain as follows, See and example below. You may need to rebuild nginx vhost and restart it:

    #echo "30d" > /etc/danginx/expires/foo.com

    How to include custom configuration file for a domain

    You may need to place the custom include file in /etc/danginx/custom/ . Then rebuild nginx vhost and restart it.

    The syntax of custom include file must be /etc/danginx/custom/domain.com. Please see an example below for the domain foo.com:

    cat >> /etc/danginx/custom/foo.com << EOF
            # Hot link protection for domain foo.com
            location ~ \.(jpg|jpeg|bmp|jif|bmp|gif|png)$ {
                     root   /home/foo/public_html/;
                     valid_referers server_names none blocked;
                     if ($invalid_referer) {
                      return 403;
                    }
            }
    EOF
                    

    How to compile nginx manually and add custom modules

    You can compile nginx with any modules are you wish from version 4.0. The procedure is easy.
    You may need to edit the nginx auto configure file /etc/danginx/configure.sh and add your custom build flags After that execute the following command to compile nginx

    /usr/local/directadmin/scripts/installnginx --version=1.2.4    
        #You can compile any stable versions of nginx as you wish

    How to enable HttpRealipModule or Cloudflare Support

    You may need to compile the nginx in your cpnginx server with the flag –with-http_realip_module
    This options is already enabled by default from danginx 4.0
    You only need to edit the nginx configuration file and add the Ips as per the documentation HttpRealipModule

    How to enable Ipv6 in Danginx

    You may need to compile the nginx in your danginx server with the flag –with-ipv6. For that please edit the file /etc/danginx/configure.sh and modify it as follows,

     #!/bin/bash
    ./configure --prefix=/usr/local/nginx  \
            --with-openssl=/usr/ \
            --with-http_realip_module \
            --with-ipv6
    
    Now compile nginx using /usr/local/directadmin/scripts/installnginx.
    Now enable ipv6 in danginx using the following command
    touch /etc/danginx/enableipv6.conf 
    Now rebuild the nginx vhost and restart the nginx server.