New update.. new problems.. with generate nginx conf "location "/" is outside location "^()(/.*)?$"

msok20

Verified User
Joined
Sep 22, 2020
Messages
36
Dear DA Team,

I am writing regarding serious issues I have encountered after performing a clean installation of the system, updates, and installing DirectAdmin along with the associated packages. Unfortunately, the server does not function properly after these operations.

The most concerning problems are:

  1. Nginx fails to start properly:
    • After removing all vhosts, the Nginx server works.
    • However, when creating any vhost, an error occurs due to invalid Nginx configuration syntax, which prevents it from starting.
  2. Incorrect PHP versions:
    • A vhost is configured to use PHP 8.3, even though the location configuration files only include settings for PHP 8.2. This indicates inconsistencies or errors in the generated configurations.
These issues are not only frustrating but also significantly impact my work efficiency. I have a few questions that I hope will help resolve these problems quickly:

  1. Do you monitor and thoroughly test the changes introduced in updates to ensure they are stable and compatible with server configurations?
  2. Are there plans to implement fixes or higher testing standards to prevent such issues in the future?
  3. How can I resolve the above issues? I would appreciate detailed instructions on fixing the PHP configuration and starting Nginx with vhosts.
I hope for a prompt response and specific support to address these problems. The current situation requires urgent action.

I dont use any custom in httpd conf!

nginx: [emerg] location "/" is outside location "^()(/.*)?$" in /usr/local/directadmin/data/users/admin/nginx.conf:88
Failed to start The nginx HTTP and reverse proxy server.


Code:
# Auto generated nginx config file by DirectAdmin version 1.670
# Modifying this file is not recommended as any changes you make will be
# overwritten when the user makes any changes to their website

# For global config changes that affect all Users, see this guide:
# http://help.directadmin.com/item.php?id=558
# For local config changes that only affect one User, see this guide:
# http://help.directadmin.com/item.php?id=3



server
{
        listen 192.168.1.1:80;
        server_name exampledomain.com www.exampledomain.com;
        access_log /var/log/nginx/domains/exampledomain.com.log;
        access_log /var/log/nginx/domains/exampledomain.com.bytes bytes;
        error_log /var/log/nginx/domains/exampledomain.com.error.log;
        root "/home/admin/domains/exampledomain.com/public_html";
        index index.php index.html index.htm;
        if ($http_x_forwarded_proto != 'https') {
                return 301 https://$host$request_uri;
        }
                # use fastcgi for all php files
                location ~ \.php$
                {
                        try_files $uri =404;
                        fastcgi_split_path_info ^(.+\.php)(/.+)$;
                        include /etc/nginx/fastcgi_params;
                        fastcgi_index index.php;
                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        if ( $skip_cache ~ "^$" ) {
                                set $skip_cache 1;
                        }
                        fastcgi_cache_bypass $skip_cache;
                        fastcgi_no_cache $skip_cache;
                        fastcgi_cache FASTCGICACHE;
                        fastcgi_cache_valid 60m;
                        include /etc/nginx/nginx_limits.conf;
                        if (-f $request_filename)
                        {
                                fastcgi_pass unix:/usr/local/php82/sockets/admin.sock;
                        }
                }
                location ~ \.(php53|php54|php55|php56|php70|php71|php72|php73|php74|php80|php81|php82)$
                {
                        deny all;
                }
location / {
try_files $uri $uri/ /index.php?$args ;
}
    # Mail auto configuration (Thunderbird)
    location = "/.well-known/autoconfig/mail/config-v1.1.xml" {
        proxy_pass http://unix:/usr/local/directadmin/shared/internal.sock;
        proxy_set_header X-Forwarded-For  $remote_addr;
        proxy_set_header X-Forwarded-Host $host;
    }
        include /etc/nginx/webapps.conf;
        location ~ "^()(/.*)?$"
        {
                set $template_location "$1/";
                set $relative_location "$2";
                include /etc/nginx/templates/wordpress.conf;
                # use fastcgi for all php files
                location ~ \.php$
                {
                        try_files $uri =404;
                        fastcgi_split_path_info ^(.+\.php)(/.+)$;
                        include /etc/nginx/fastcgi_params;
                        fastcgi_index index.php;
                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        if ( $skip_cache ~ "^$" ) {
                                set $skip_cache 1;
                        }
                        fastcgi_cache_bypass $skip_cache;
                        fastcgi_no_cache $skip_cache;
                        fastcgi_cache FASTCGICACHE;
                        fastcgi_cache_valid 60m;
                        include /etc/nginx/nginx_limits.conf;
                        if (-f $request_filename)
                        {
                                fastcgi_pass unix:/usr/local/php82/sockets/admin.sock;
                        }
                }
                location ~ \.(php53|php54|php55|php56|php70|php71|php72|php73|php74|php80|php81|php82)$
                {
                        deny all;
                }
location / {
try_files $uri $uri/ /index.php?$args ;
}
        }
}

server
{
        listen 192.168.1.1:443 ssl;
        http2 on;
        server_name exampledomain.com www.exampledomain.com;
        access_log /var/log/nginx/domains/exampledomain.com.log;
        access_log /var/log/nginx/domains/exampledomain.com.bytes bytes;
        error_log /var/log/nginx/domains/exampledomain.com.error.log;
        root "/home/admin/domains/exampledomain.com/private_html";
        index index.php index.html index.htm;
        ssl_certificate /usr/local/directadmin/data/users/admin/domains/exampledomain.com.cert.combined;
        ssl_certificate_key /usr/local/directadmin/data/users/admin/domains/exampledomain.com.key;
                # use fastcgi for all php files
                location ~ \.php$
                {
                        try_files $uri =404;
                        fastcgi_split_path_info ^(.+\.php)(/.+)$;
                        include /etc/nginx/fastcgi_params;
                        fastcgi_index index.php;
                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        if ( $skip_cache ~ "^$" ) {
                                set $skip_cache 1;
                        }
                        fastcgi_cache_bypass $skip_cache;
                        fastcgi_no_cache $skip_cache;
                        fastcgi_cache FASTCGICACHE;
                        fastcgi_cache_valid 60m;
                        include /etc/nginx/nginx_limits.conf;
                        if (-f $request_filename)
                        {
                                fastcgi_pass unix:/usr/local/php82/sockets/admin.sock;
                        }
                }
                location ~ \.(php53|php54|php55|php56|php70|php71|php72|php73|php74|php80|php81|php82)$
                {
                        deny all;
                }
location / {
try_files $uri $uri/ /index.php?$args ;
}
    # Mail auto configuration (Thunderbird)
    location = "/.well-known/autoconfig/mail/config-v1.1.xml" {
        proxy_pass http://unix:/usr/local/directadmin/shared/internal.sock;
        proxy_set_header X-Forwarded-For  $remote_addr;
        proxy_set_header X-Forwarded-Host $host;
    }
        include /etc/nginx/webapps.ssl.conf;
        location ~ "^()(/.*)?$"
        {
                set $template_location "$1/";
                set $relative_location "$2";
                include /etc/nginx/templates/wordpress.conf;
                # use fastcgi for all php files
                location ~ \.php$
                {
                        try_files $uri =404;
                        fastcgi_split_path_info ^(.+\.php)(/.+)$;
                        include /etc/nginx/fastcgi_params;
                        fastcgi_index index.php;
                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        if ( $skip_cache ~ "^$" ) {
                                set $skip_cache 1;
                        }
                        fastcgi_cache_bypass $skip_cache;
                        fastcgi_no_cache $skip_cache;
                        fastcgi_cache FASTCGICACHE;
                        fastcgi_cache_valid 60m;
                        include /etc/nginx/nginx_limits.conf;
                        if (-f $request_filename)
                        {
                                fastcgi_pass unix:/usr/local/php82/sockets/admin.sock;
                        }
                }
                location ~ \.(php53|php54|php55|php56|php70|php71|php72|php73|php74|php80|php81|php82)$
                {
                        deny all;
                }
location / {
try_files $uri $uri/ /index.php?$args ;
}
        }
}
 
location / { try_files $uri $uri/ /index.php?$args ; }

Hello,

Is this a custom code added by you? Or is it a template for WordPress selected in DirectAdmin?

I see the block:

Code:
location / {
try_files $uri $uri/ /index.php?$args ;
}

is added twice per a server {} section. I doubt it is natively. Even if you write you don't use custom in httpd.conf. What do you see when run the following code?

Code:
ls -al /usr/local/directadmin/data/templates/custom/

p.s. You might try and downgrade DirectAdmin to a stable release, if everything is really native no single custom template exists on the server.
 
Back
Top