Page 1 of 16 12311 ... LastLast
Results 1 to 20 of 305

Thread: Reverse-proxy NGINX + Apache on Directadmin powered server with CB 2.x

  1. #1
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    12,205

    Reverse-proxy NGINX + Apache on Directadmin powered server with CB 2.x

    Custombuild 2 allows us to have a reverse-proxy NGINX + Apache on Directadmin powered server without a need for any 3rd party scripts or plugins, addons. That's quite easy to start using it.


    CustomBuild 2.x version

    First of all make sure you've got custombuild 2:
    Code:
    cd /usr/local/directadmin/custombuild
    ./build version
    You should see an output similar to the following:
    Code:
    [root@server custombuild]# ./build version
    2.0.0-RC7 (rev: 863)

    If it differes much then you've got custombuild 1.x


    Directadmin version

    To check directadmin version run this code:
    Code:
    [root@server custombuild]# /usr/local/directadmin/directadmin v
    Version: DirectAdmin v.1.45.4
    Make sure to have version of directadmin no less than 1.45.2 otherwise the things won't work.


    Custombuild 2.x: NGINX + Apache

    Run this code to build nginx + apache with custombuild:
    Code:
    cd /usr/local/directadmin/custombuild
    ./build update
    ./build update_da
    ./build set webserver nginx_apache
    ./build nginx_apache
    ./build rewrite_confs
    That's it. Have fun with it.


    UPDATE #1: Real IP on Apache`s server-status page (*** ACTUAL VERSION OF APACHE SHOULD HAVE IT FIXED ALREADY ***)

    Please do not follow this update #1 if you have the latest apache version with a patch that fixes the issue!

    Apache gets real IPs, you may see it in $_SERVER with PHP or in apache logs; but it shows incorrect IP in apache's server status.

    Before to start, please make sure to have unzip installed on your server:

    On RHEL/CentOS
    Code:
    yum install unzip
    On Debian/Ubuntu
    Code:
    apt-get install unzip
    To get real IPs instead 127.0.0.1 on Apache`s server-status page you need to install mod_rpaf, as remoteip is buggy in this case:

    Code:
    cd /usr/local/src
    wget https://github.com/y-ken/mod_rpaf/archive/master.zip
    unzip master.zip
    cd mod_rpaf-master
    /bin/sed -i "s/remote_/client_/g" mod_rpaf-2.0.c
    make && make install
    and insert following instructions:

    Code:
    LoadModule rpaf_module      /usr/lib/apache/mod_rpaf-2.0.so
    <IfModule mod_rpaf-2.0.c>
        RPAFenable On
        RPAFproxy_ips 127.0.0.1
        RPAFsethostname On
        RPAFheader X-Client-IP
    </IfModule>
    into /etc/httpd/conf/extra/httpd-includes.conf and restart apache.
    Last edited by zEitEr; 07-08-2015 at 10:50 PM. Reason: UPDATE 1 added + comments, UPDATE 2: fixed typo

  2. #2
    Join Date
    Mar 2005
    Location
    Kingdom of Bahrain
    Posts
    961

  3. #3
    Join Date
    Apr 2014
    Location
    Netherlands
    Posts
    64
    Thanks!

    But is this a viable configuration on a Sharedhosting environment?

    My current configuration
    Apache + Mod_Ruid2 (CLI)
    Marc

    # Hexweb.nl

  4. #4
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    12,205
    You're welcome.

    But is this a viable configuration on a Sharedhosting environment?


    Yes, it is. You may use NGINX+Apache with m
    od_ruid2 (CLI).

  5. #5
    Join Date
    Apr 2014
    Location
    Netherlands
    Posts
    64
    I've installed it on my servers and the increase in performance is huge!
    The Initial load and the load times between pages have decreased dramaticly!

    Great work on the how to
    Marc

    # Hexweb.nl

  6. #6
    Join Date
    Apr 2014
    Location
    Netherlands
    Posts
    64
    Another addition:

    If you get a 504 Gateway Timeout.
    Add these settings below http{

    /etc/nginx/nginx.conf
    Code:
    proxy_connect_timeout       600;
    proxy_send_timeout          600;
    proxy_read_timeout          600;
    send_timeout                600;
    Marc

    # Hexweb.nl

  7. #7
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    12,205
    Marc,

    to protect your modificatations, you should now update the file:

    /usr/local/directadmin/custombuild/configure/nginx_reverse/conf/nginx.conf

    the same way and copy it to

    /usr/local/directadmin/custombuild/custom/nginx_reverse/conf/nginx.conf

    Create a directory /usr/local/directadmin/custombuild/custom/nginx_reverse/conf/ if does not exist.

    That will protect your changes against being lost.

  8. #8
    Join Date
    Apr 2014
    Location
    Netherlands
    Posts
    64
    Heey Alex,

    Thanks for the info.
    I've added it too the files.
    Marc

    # Hexweb.nl

  9. #9
    Join Date
    May 2005
    Location
    Ukraine, Kiev
    Posts
    115
    Hi!

    Is there any way to host multiple SSL sites with DA + Nginx on one IP address, but with different certificates?

    In clear nginx+apache setup I can do this very easy by just proxying nginx SSL front to plain apache backend, but with DirectAdmin its looks impossible to me, because DA says: "You can only add a certificate if you own the ip you are using".

    Is there any ideas?

  10. #10
    Join Date
    May 2005
    Location
    Ukraine, Kiev
    Posts
    115

    Solved.

    Found that enable_ssl_sni=1 in directadmin.conf do exactly what I need.

  11. #11
    Join Date
    Aug 2006
    Location
    LT, EU
    Posts
    7,099
    Please check http://www.directadmin.com/features.php?id=1100, if you'd like to have SNI enabled for a shared IP.
    Martynas Bendorius
    MB Martynas IT. Professional server management company. Official DirectAdmin, CloudLinux, LiteSpeed and Comodo partners.

  12. #12
    Join Date
    May 2005
    Location
    Ukraine, Kiev
    Posts
    115
    Thank you! Already solved my problem

  13. #13
    Join Date
    Mar 2014
    Posts
    8
    After switch from 3rd party reverse proxy nginx-apache to DA nginx_apache and do all steps same as first post then my websites are display same errors in the blank page:

    Apache is functioning normally

    How can I solve it ?

  14. #14
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    12,205
    You should remove all custom virtual_host2*.conf templates from /usr/local/directadmin/data/tempates/custom/ :


    Code:
    cd /usr/local/directadmin/data/templates/custom
    rm -fv virtual_host2*.conf

    and rewrite all virtual hosts:

    Code:
    echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue
    let it upto 3-4 minutes to complete and check your web-sites.
    Last edited by zEitEr; 08-09-2014 at 11:37 AM.

  15. #15
    Join Date
    Mar 2014
    Posts
    8
    Quote Originally Posted by zEitEr View Post
    You should remove all custom virtual_host2*.conf templates from /usr/local/directadmin/data/tempates/custom/ :


    Code:
    cd /usr/local/directadmin/data/templates
    rm -fv virtual_host2*.conf

    and rewrite all virtual hosts:

    Code:
    echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue
    let it upto 3-4 minutes to complete and check your web-sites.
    It take 3-4 min. or I should wait for 3-4 min. ?

    run above commands but still nothing, same as before...

  16. #16
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    12,205
    Please show here an apache's virtual host for a domain.

  17. #17
    Join Date
    Mar 2014
    Posts
    8
    Quote Originally Posted by zEitEr View Post
    Please show here an apache's virtual host for a domain.
    After running above commands that you wrote, only available

    Code:
    <Directory "/home/fsaco/public_html">
            <IfModule mod_ruid2.c>
                    RMode config
                    RUidGid fsaco fsaco
                    #RGroups apache access
                    RGroups @none
            </IfModule>
    </Directory>

  18. #18
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    12,205
    That's something wrong, please provide admin acces into directadmin so I could see it myself.

  19. #19
    Join Date
    Mar 2014
    Posts
    8
    Quote Originally Posted by zEitEr View Post
    That's something wrong, please provide admin acces into directadmin so I could see it myself.
    Thank you, I want sent you PM but your PM Box is full

  20. #20
    Join Date
    Aug 2006
    Location
    LT, EU
    Posts
    7,099
    Quote Originally Posted by sIiiS View Post
    After running above commands that you wrote, only available

    Code:
    <Directory "/home/fsaco/public_html">
            <IfModule mod_ruid2.c>
                    RMode config
                    RUidGid fsaco fsaco
                    #RGroups apache access
                    RGroups @none
            </IfModule>
    </Directory>
    That's a normal behavior. You removed DirectAdmin original (not customized templates) with the commands given, now you should manually update DA to get them back or install DA pre-release binaries Please check for custom virtual_host2.conf templates in /usr/local/directadmin/data/templates/custom next time, but it seems you did not have them.
    Martynas Bendorius
    MB Martynas IT. Professional server management company. Official DirectAdmin, CloudLinux, LiteSpeed and Comodo partners.

Page 1 of 16 12311 ... LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •