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

Hi, I have a virtual server with root and custom build 2. I don't know if config files were changed. Is it safe to use this instruction to add nginx? I have several websites running on apache and I don't want to spoil anything.
In now you can use custombuild gui to build your nginx_apache without edit anything
 
After change from apache2 to nginx_apache and rewrite confs, apache is working on port 8080 but nginx is not listetning on port 80. Why ? How can i Solve this?

Code:
tcp        0      0 0.0.0.0:993             0.0.0.0:*               LISTEN      464/dovecot/imap-lo
tcp        0      0 0.0.0.0:995             0.0.0.0:*               LISTEN      505/dovecot/pop3-lo
tcp        0      0 0.0.0.0:587             0.0.0.0:*               LISTEN      26172/exim         
tcp        0      0 0.0.0.0:110             0.0.0.0:*               LISTEN      505/dovecot/pop3-lo
tcp        0      0 0.0.0.0:143             0.0.0.0:*               LISTEN      464/dovecot/imap-lo
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      24531/httpd         
tcp        0      0 0.0.0.0:8081            0.0.0.0:*               LISTEN      24531/httpd         
tcp        0      0 0.0.0.0:465             0.0.0.0:*               LISTEN      26172/exim         
tcp        0      0 127.0.0.2:53            0.0.0.0:*               LISTEN      884/named           
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      884/named           
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      197/pure-ftpd       
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      328/sshd           
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      26172/exim         
tcp        0      0 127.0.0.1:953           0.0.0.0:*               LISTEN      884/named           
tcp6       0      0 :::3306                 :::*                    LISTEN      7019/mysqld         
tcp6       0      0 :::2222                 :::*                    LISTEN      9709/directadmin   
tcp6       0      0 :::53                   :::*                    LISTEN      884/named           
tcp6       0      0 :::21                   :::*                    LISTEN      197/pure-ftpd       
tcp6       0      0 :::22                   :::*                    LISTEN      328/sshd           
tcp6       0      0 ::1:953                 :::*                    LISTEN      884/named
 
I have a cloud server (Ubuntu 16 with DirectAdmin installed) that has a running node.js app (port 3000), how can I direct incoming requests to port 443 to the node.js app using Nginx with DirectAdmin?
Is configuring Nginx with DirectAdmin different from configuring without it? (I previously put the config file in /etc/nginx/sites-enabled/, But what do I do now?)
 
Hi, I'm using nginx_apache as web server but when I look at apache server-status I see static files being served over apache. I was under the impression that they were supposed to be served via nginx according to the docs here. I'm not sure how to troubleshoot or fix this and couldn't find anything useful in the forums yet. Is this the right place to ask for help? Thanks
 
Hi, I had nginx installed on my vps before going through the procedure. Inside sites-available I have set default redirection to redmine app. It was working as a harm before. After the procedure DA redirects properly my domains, but my default redirection has stopped working, at all. Just like it just stop checking what is in sites-enabled (yes I have included it before other includes of the config. proxy looks like below.

upstream app {
# Path to Puma SOCK file, as defined previously
server unix:/home/redmine/redmine/shared/sockets/puma.sock fail_timeout=0;
}

server {
listen 80;
server_name localhost;

root /home/redmine/redmine/public;

try_files $uri/index.html $uri @app;

location @app {
proxy_pass http://app;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}

error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
 
i run command
Code:
./build nginx_apache
Then
Code:
2021-09-26 22:43:28 (505 MB/s) - '/etc/logrotate.d/nginx' saved [186/186]

Restarting nginx.
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
[root@vmi678827 custombuild]#

:( How fix it :(

Run systemctl status nginx.service

Code:
[root@vmi678827 custombuild]# systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/etc/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sun 2021-09-26 22:45:01 +08; 3s ago
  Process: 400598 ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)

Sep 26 22:45:01 sv.nadigi.vn systemd[1]: Starting The nginx HTTP and reverse proxy server...
Sep 26 22:45:01 sv.nadigi.vn nginx[400598]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Sep 26 22:45:01 sv.nadigi.vn nginx[400598]: nginx: [emerg] bind() to [::1]:80 failed (99: Cannot assign requested address)
Sep 26 22:45:01 sv.nadigi.vn nginx[400598]: nginx: configuration file /etc/nginx/nginx.conf test failed
Sep 26 22:45:01 sv.nadigi.vn systemd[1]: nginx.service: Control process exited, code=exited status=1
Sep 26 22:45:01 sv.nadigi.vn systemd[1]: nginx.service: Failed with result 'exit-code'.
Sep 26 22:45:01 sv.nadigi.vn systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
 
nginx: [emerg] bind() to [::1]:80 failed (99: Cannot assign requested address)
do you have IPv6?
 
Did you follow all the instructions when switching web servers?

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

 
nginx: [emerg] bind() to [::1]:80 failed (99: Cannot assign requested address)
do you have IPv6?
No, i don't have ipv6
Did you follow all the instructions when switching web servers?

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

yes, i run to ./build nginx_apache then error
 
comment out at
/etc/nginx/nginx-vhosts.conf
#listen [::1]:80;
This is content file nginx-vhost.conf
Code:
   server {
        listen       194.233.80.18:80;
        listen       127.0.0.1:80;
        listen       [::1]:80;

        server_name  $hostname 194.233.80.18;

        root   /var/www/html;

        #include /etc/nginx/nginx-userdir.conf;

        location / {
                access_log off;
                proxy_pass http://194.233.80.18:8080;
                proxy_set_header X-Client-IP      $remote_addr;
                proxy_set_header X-Accel-Internal /nginx_static_files;
                proxy_set_header Host             $host;
                proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
                proxy_hide_header Upgrade;
        }

        location /nginx_static_files/ {
                access_log  /var/log/nginx/access_log_proxy;
                alias       /var/www/html/;
                internal;
        }
    
        # deny access to .htaccess, .env and .user.ini files
        location ~ /(\.ht|\.env|\.user\.ini) {
                deny  all;
        }
        
        include /etc/nginx/nginx-info.conf;
        include /etc/nginx/webapps.hostname.conf;
    }

    # HTTPS server
    #
    server {
        listen       194.233.80.18:443 ssl http2;
        listen       127.0.0.1:443 ssl http2;
        listen       [::1]:443 ssl http2;

        server_name  $hostname 194.233.80.18;

        ssl_certificate        /etc/httpd/conf/ssl.crt/server.crt.combined;
        ssl_certificate_key    /etc/httpd/conf/ssl.key/server.key;

        root   /var/www/html;

        #include /etc/nginx/nginx-userdir.conf;

        location / {
                access_log off;
                proxy_pass https://194.233.80.18:8081;
                proxy_set_header X-Client-IP      $remote_addr;
                proxy_set_header X-Accel-Internal /nginx_static_files;
                proxy_set_header Host             $host;
                proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
                proxy_hide_header Upgrade;
        }

        location /nginx_static_files/ {
                access_log  /var/log/nginx/access_log_proxy;
                alias       /var/www/html/;
                internal;
        }
    
        # deny access to .htaccess, .env and .user.ini files
        location ~ /(\.ht|\.env|\.user\.ini) {
                deny  all;
        }
        
        include /etc/nginx/nginx-info.conf;
        include /etc/nginx/webapps.hostname.conf;
    }
 
I know,
just comment
listen [::1]:80; in beginning
and
listen [::1]:443 ssl http2; in middle of file
 
I know,
just comment
listen [::1]:80; in beginning
and
listen [::1]:443 ssl http2; in middle of file
Thanks you.
After I commented # nginx was running. But when i run command ./build rewrite_confs then same error.
I check file /etc/nginx/nginx-vhosts.conf then it's back to the way it was before I added #. What can I do?
 
you need to disable ipv6, maybe you have ipv6 localhost at your network device
 
how do disable ipv6?
i have added net.ipv6.conf.all.disable_ipv6 = 1 to /etc/sysctl.conf

it is work? please help me
 
Back
Top