apacha+nginx rewrite_confs fails nginx to start because of alias webapps

Tootle

Verified User
Joined
Sep 1, 2011
Messages
39
I want a custom alias for webapp so i did

https://help.directadmin.com/item.php?id=599

result

Code:
[root@server][/usr/local/directadmin/custombuild]
$ ./build rewrite_confs
Checking to ensure /etc/httpd/conf/ssl.crt/server.ca is set.
Adding custom webapps from /usr/local/directadmin/custombuild/custom/webapps.list
Added .well-known pointing to .well-known
Added poczta pointing to roundcube
Using 1xx.xx.xx.xx for your server IP
Found /usr/local/directadmin/custombuild/mod_aclr2-1.0.0.tar.gz
Extracting /usr/local/directadmin/custombuild/mod_aclr2-1.0.0.tar.gz...
Installing mod_aclr2-1.0.0...
/var/www/build/libtool --silent --mode=compile gcc -std=gnu99 -prefer-pic -I/usr/local/include  -DLINUX -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/apache  -I/usr/include/apache   -I/usr/include/apache   -c -o mod_aclr2.lo mod_aclr2.c && touch mod_aclr2.slo
/var/www/build/libtool --silent --mode=link gcc -std=gnu99 -L/usr/local/lib   -o mod_aclr2.la  -rpath /usr/lib/apache -module -avoid-version    mod_aclr2.lo
/var/www/build/instdso.sh SH_LIBTOOL='/var/www/build/libtool' mod_aclr2.la /usr/lib/apache
/var/www/build/libtool --mode=install install mod_aclr2.la /usr/lib/apache/
libtool: install: install .libs/mod_aclr2.so /usr/lib/apache/mod_aclr2.so
libtool: install: install .libs/mod_aclr2.lai /usr/lib/apache/mod_aclr2.la
libtool: install: install .libs/mod_aclr2.a /usr/lib/apache/mod_aclr2.a
libtool: install: chmod 644 /usr/lib/apache/mod_aclr2.a
libtool: install: ranlib /usr/lib/apache/mod_aclr2.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/sbin" ldconfig -n /usr/lib/apache
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/lib/apache

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
chmod 755 /usr/lib/apache/mod_aclr2.so
[activating module `aclr' in /etc/httpd/conf/httpd.conf]
mod_aclr2 has been installed successfully.
Restarting apache.
Adding custom webapps from /usr/local/directadmin/custombuild/custom/webapps.list
Added .well-known pointing to .well-known
Added poczta pointing to roundcube
Checking to ensure /etc/httpd/conf/ssl.crt/server.ca is set.
Using 1xx.xx.xx.xx for your server IP
Using 1xx.xx.xx.xx for your server IP
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.

and nginx will not start because it has double definitions in
webapps.ssl.conf and webapps.conf

i have to remove them manually then nginx starts
 
What's inside /usr/local/directadmin/custombuild/custom/webapps.list ? May you also attach the content of webapps.ssl.conf and webapps.conf ?
 
Code:
[root@server][~]
$ cat /usr/local/directadmin/custombuild/custom/webapps.list
.well-known=.well-known
poczta=roundcube

Code:
  location ^~ /.well-known {
                root /var/www/html/;
                index index.php index.html index.htm;
                location ~ ^/.well-known/ {
                        access_log off;
                set $my_server_addr $server_addr;
                if ($server_addr ~ ^[0-9a-fA-F:]+$) { set $my_server_addr [$server_addr]; }
                        proxy_pass http://$my_server_addr:8080;
                        proxy_set_header X-Client-IP      $remote_addr;
                        proxy_set_header X-Accel-Internal /.well-known/nginx_static_files;
                        proxy_set_header Host        $host;
                        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
                }
                location ~ ^/.well-known/nginx_static_files/ {
                        access_log  /var/log/nginx/access_log_proxy;
                        alias       /var/www/html/;
                        internal;
                }
        }
        location ^~ /roundcube {
                root /var/www/html/;
                index index.php index.html index.htm;
                location ~ ^/roundcube/ {
                        access_log off;
                set $my_server_addr $server_addr;
                if ($server_addr ~ ^[0-9a-fA-F:]+$) { set $my_server_addr [$server_addr]; }
                        proxy_pass http://$my_server_addr:8080;
                        proxy_set_header X-Client-IP      $remote_addr;
                        proxy_set_header X-Accel-Internal /roundcube/nginx_static_files;
                        proxy_set_header Host        $host;
                        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
                }
                location ~ ^/roundcube/nginx_static_files/ {
                        access_log  /var/log/nginx/access_log_proxy;
                        alias       /var/www/html/;
                        internal;
                }
        }
        location ^~ /phpMyAdmin {
                root /var/www/html/;
                index index.php index.html index.htm;
                location ~ ^/phpMyAdmin/ {
                        access_log off;
                set $my_server_addr $server_addr;
                if ($server_addr ~ ^[0-9a-fA-F:]+$) { set $my_server_addr [$server_addr]; }
                        proxy_pass http://$my_server_addr:8080;
                        proxy_set_header X-Client-IP      $remote_addr;
                        proxy_set_header X-Accel-Internal /phpMyAdmin/nginx_static_files;
                        proxy_set_header Host        $host;
                        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
                }
                location ~ ^/phpMyAdmin/nginx_static_files/ {
                        access_log  /var/log/nginx/access_log_proxy;
                        alias       /var/www/html/;
                        internal;
                }
        }
        location ~ ^/phpmyadmin {
                rewrite ^/* /phpMyAdmin last;
        }
        location ~ ^/pma {
        rewrite ^/* /phpMyAdmin last;
        }
        location ~ ^/webmail {
                rewrite ^/* /roundcube last;
        }
        if ($request_method !~ ^(GET|HEAD|POST)$ ) {
                return 444;
        }
        location ~ /(\.htaccess|\.htpasswd|\.user\.ini) {
                deny all;
        }
        location ~ /roundcube/(bin|SQL|config|logs|temp)/ {
                deny all;
        }
        location ~ /phpMyAdmin/log/ {
                deny all;
        }

the thing is: when i do a $ ./build rewrite_confs
i've end with additional FULL definitions in

location ^~ /.well-known {
location ^~ /roundcube {

at the bottom of those nginx includes, so I assume it is an append without checking the existence
 
so now i did:
Code:
[root@server][/usr/local/directadmin/custombuild]
$ ./build rewrite_confs
and
Code:
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.
webapps.conf
Code:
 location ^~ /.well-known {
                root /var/www/html/;
                index index.php index.html index.htm;
                location ~ ^/.well-known/ {
                        access_log off;
                set $my_server_addr $server_addr;
                if ($server_addr ~ ^[0-9a-fA-F:]+$) { set $my_server_addr [$server_addr]; }
                        proxy_pass http://$my_server_addr:8080;
                        proxy_set_header X-Client-IP      $remote_addr;
                        proxy_set_header X-Accel-Internal /.well-known/nginx_static_files;
                        proxy_set_header Host        $host;
                        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
                }
                location ~ ^/.well-known/nginx_static_files/ {
                        access_log  /var/log/nginx/access_log_proxy;
                        alias       /var/www/html/;
                        internal;
                }
        }
        location ^~ /roundcube {
                root /var/www/html/;
                index index.php index.html index.htm;
                location ~ ^/roundcube/ {
                        access_log off;
                set $my_server_addr $server_addr;
                if ($server_addr ~ ^[0-9a-fA-F:]+$) { set $my_server_addr [$server_addr]; }
                        proxy_pass http://$my_server_addr:8080;
                        proxy_set_header X-Client-IP      $remote_addr;
                        proxy_set_header X-Accel-Internal /roundcube/nginx_static_files;
                        proxy_set_header Host        $host;
                        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
                }
                location ~ ^/roundcube/nginx_static_files/ {
                        access_log  /var/log/nginx/access_log_proxy;
                        alias       /var/www/html/;
                        internal;
                }
        }
        location ^~ /phpMyAdmin {
                root /var/www/html/;
                index index.php index.html index.htm;
                location ~ ^/phpMyAdmin/ {
                        access_log off;
                set $my_server_addr $server_addr;
                if ($server_addr ~ ^[0-9a-fA-F:]+$) { set $my_server_addr [$server_addr]; }
                        proxy_pass http://$my_server_addr:8080;
                        proxy_set_header X-Client-IP      $remote_addr;
                        proxy_set_header X-Accel-Internal /phpMyAdmin/nginx_static_files;
                        proxy_set_header Host        $host;
                        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
                }
                location ~ ^/phpMyAdmin/nginx_static_files/ {
                        access_log  /var/log/nginx/access_log_proxy;
                        alias       /var/www/html/;
                        internal;
                }
        }
        location ~ ^/phpmyadmin {
                rewrite ^/* /phpMyAdmin last;
        }
        location ~ ^/pma { rewrite ^/* /phpMyAdmin last;
        }
        location ~ ^/webmail {
                rewrite ^/* /roundcube last;
        }
        if ($request_method !~ ^(GET|HEAD|POST)$ ) {
                return 444;
        }
        location ~ /(\.htaccess|\.htpasswd|\.user\.ini) {
                deny all;
        }
        location ~ /roundcube/(bin|SQL|config|logs|temp)/ {
                deny all;
        }
        location ~ /phpMyAdmin/log/ {
                deny all;
        }
        location ^~ /.well-known {
                root /var/www/html/;
                index index.php index.html index.htm;
                location ~ ^/.well-known/ {
                        access_log off;
                set $my_server_addr $server_addr;
                if ($server_addr ~ ^[0-9a-fA-F:]+$) { set $my_server_addr [$server_addr]; }
                        proxy_pass http://$my_server_addr:8080;
                        proxy_set_header X-Client-IP      $remote_addr;
                        proxy_set_header X-Accel-Internal /.well-known/nginx_static_files;
                        proxy_set_header Host        $host;
                        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
                }
                location ~ ^/.well-known/nginx_static_files/ {
  access_log  /var/log/nginx/access_log_proxy;
                        alias       /var/www/html/;
                        internal;
                }
        }
        location ^~ /roundcube {
                root /var/www/html/;
                index index.php index.html index.htm;
                location ~ ^/roundcube/ {
                        access_log off;
                set $my_server_addr $server_addr;
                if ($server_addr ~ ^[0-9a-fA-F:]+$) { set $my_server_addr [$server_addr]; }
                        proxy_pass http://$my_server_addr:8080;
                        proxy_set_header X-Client-IP      $remote_addr;
                        proxy_set_header X-Accel-Internal /roundcube/nginx_static_files;
                        proxy_set_header Host        $host;
                        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
                }
                location ~ ^/roundcube/nginx_static_files/ {
                        access_log  /var/log/nginx/access_log_proxy;
                        alias       /var/www/html/;
                        internal;
                }
        }

Code:
2017/03/24 15:02:07 [emerg] 9304#0: duplicate location "/.well-known" in /etc/nginx/webapps.conf:79
2017/03/24 15:03:03 [emerg] 9337#0: duplicate location "/.well-known" in /etc/nginx/webapps.ssl.conf:79

I must remove those two definitions at the bottom of the files webapps.ssl.conf and webapps.conf then nginx starts OK.
 
Last edited:
.well-known is managed automatically by DA, if letsencrypt=1 is set, you don't need to have it in webapps.list.
 
.well-known is managed automatically by DA, if letsencrypt=1 is set, you don't need to have it in webapps.list.

Hmm, first of all I needed to do this,
https://help.directadmin.com/item.php?id=646
because let's encrypt cert generation failed in DA (.well-known)

But the /roundcube alias is also doubled when rewriting confs, so... I don't get it.

Nevertheless, so You're sayin that I shall manually remove
Code:
.well-known=.well-known
from webapps.list then?
 
Back
Top