0

My laravel sites are hosted at Versio.nl. Recently they did maintenance on the servers and since then my subdomains are down.

I found a strange set of document roots.

In the DirectAdmin panel under custom httpd configurations I added:

|*if !SUB|
|?DOCROOT=/home/admin/domains/netwerkspel.nl/public_html/public|
|*endif|

|*if SUB="demo"|
|?DOCROOT=/home/admin/domains/netwerkspel.nl/public_html/demo/public|
|*endif|

|*if SUB="avn"| 
|?DOCROOT=/home/admin/domains/netwerkspel.nl/public_html/avn/public|
|*endif|

The laravel applications are in these directories.

Now I see that in the contents of the httpd.conf the paths changed to:

<VirtualHost 185.xxx:80 >
    ServerName www.ai.netwerkspel.nl
    ServerAlias www.ai.netwerkspel.nl ai.netwerkspel.nl 
    ServerAdmin webmaster@netwerkspel.nl
    DocumentRoot /home/admin/domains/netwerkspel.nl/public_html/ai/public/ai   <<--------
    ScriptAlias /cgi-bin/ /home/admin/domains/netwerkspel.nl/public_html/ai/public/ai/cgi-bin/
    UseCanonicalName OFF
    <IfModule !mod_ruid2.c>
        SuexecUserGroup admin admin
    </IfModule>
    CustomLog /var/log/httpd/domains/netwerkspel.nl.ai.bytes bytes
    CustomLog /var/log/httpd/domains/netwerkspel.nl.ai.log combined
    ErrorLog /var/log/httpd/domains/netwerkspel.nl.ai.error.log
    <Directory /home/admin/domains/netwerkspel.nl/public_html/ai/public/ai>
        <FilesMatch "\.(inc|php|phtml|phps|php74)$">
            <If "-f %{REQUEST_FILENAME}">
                #ProxyErrorOverride on
                AddHandler "proxy:unix:/usr/local/php74/sockets/admin.sock|fcgi://localhost" .inc .php .phtml .php74
            </If>
        </FilesMatch>
    </Directory>
</VirtualHost>

<VirtualHost 185.xxx:443 >
    SSLEngine on
    SSLCertificateFile /usr/local/directadmin/data/users/admin/domains/netwerkspel.nl.cert.combined
    SSLCertificateKeyFile /usr/local/directadmin/data/users/admin/domains/netwerkspel.nl.key
    ServerName www.ai.netwerkspel.nl
    ServerAlias www.ai.netwerkspel.nl ai.netwerkspel.nl 
    ServerAdmin webmaster@netwerkspel.nl
    DocumentRoot /home/admin/domains/netwerkspel.nl/public_html/ai/public/ai   <<--------
    ScriptAlias /cgi-bin/ /home/admin/domains/netwerkspel.nl/public_html/ai/public/ai/cgi-bin/
    UseCanonicalName OFF
    <IfModule !mod_ruid2.c>
        SuexecUserGroup admin admin
    </IfModule>
    CustomLog /var/log/httpd/domains/netwerkspel.nl.ai.bytes bytes
    CustomLog /var/log/httpd/domains/netwerkspel.nl.ai.log combined
    ErrorLog /var/log/httpd/domains/netwerkspel.nl.ai.error.log
    <Directory /home/admin/domains/netwerkspel.nl/public_html/ai/public/ai>
        <FilesMatch "\.(inc|php|phtml|phps|php74)$">
            <If "-f %{REQUEST_FILENAME}">
                #ProxyErrorOverride on
                AddHandler "proxy:unix:/usr/local/php74/sockets/admin.sock|fcgi://localhost" .inc .php .phtml .php74
            </If>
        </FilesMatch> 
    </Directory>
</VirtualHost>

<VirtualHost 185.xxxx:80 >
    ServerName www.avn.netwerkspel.nl
    ServerAlias www.avn.netwerkspel.nl avn.netwerkspel.nl 
    ServerAdmin webmaster@netwerkspel.nl
    DocumentRoot /home/admin/domains/netwerkspel.nl/public_html/avn/public/avn    <<--------
    ScriptAlias /cgi-bin/ /home/admin/domains/netwerkspel.nl/public_html/avn/public/avn/cgi-bin/
    UseCanonicalName OFF
    <IfModule !mod_ruid2.c>
        SuexecUserGroup admin admin
    </IfModule>
    CustomLog /var/log/httpd/domains/netwerkspel.nl.avn.bytes bytes
    CustomLog /var/log/httpd/domains/netwerkspel.nl.avn.log combined
    ErrorLog /var/log/httpd/domains/netwerkspel.nl.avn.error.log
    <Directory /home/admin/domains/netwerkspel.nl/public_html/avn/public/avn>
        <FilesMatch "\.(inc|php|phtml|phps|php74)$">
            <If "-f %{REQUEST_FILENAME}">
                #ProxyErrorOverride on
                AddHandler "proxy:unix:/usr/local/php74/sockets/admin.sock|fcgi://localhost" .inc .php .phtml .php74
            </If>
        </FilesMatch>
    </Directory>
</VirtualHost>

<VirtualHost 185.xxx:443 >
    SSLEngine on
    SSLCertificateFile /usr/local/directadmin/data/users/admin/domains/netwerkspel.nl.cert.combined
    SSLCertificateKeyFile /usr/local/directadmin/data/users/admin/domains/netwerkspel.nl.key
    ServerName www.avn.netwerkspel.nl
    ServerAlias www.avn.netwerkspel.nl avn.netwerkspel.nl 
    ServerAdmin webmaster@netwerkspel.nl
    DocumentRoot /home/admin/domains/netwerkspel.nl/public_html/avn/public/avn   <<--------
    ScriptAlias /cgi-bin/ /home/admin/domains/netwerkspel.nl/public_html/avn/public/avn/cgi-bin/
    UseCanonicalName OFF
    <IfModule !mod_ruid2.c>
        SuexecUserGroup admin admin
    </IfModule>
    CustomLog /var/log/httpd/domains/netwerkspel.nl.avn.bytes bytes
    CustomLog /var/log/httpd/domains/netwerkspel.nl.avn.log combined
    ErrorLog /var/log/httpd/domains/netwerkspel.nl.avn.error.log
    <Directory /home/admin/domains/netwerkspel.nl/public_html/avn/public/avn>
        <FilesMatch "\.(inc|php|phtml|phps|php74)$">
            <If "-f %{REQUEST_FILENAME}">
                #ProxyErrorOverride on
                AddHandler "proxy:unix:/usr/local/php74/sockets/admin.sock|fcgi://localhost" .inc .php .phtml .php74
            </If>
        </FilesMatch> 
    </Directory>
</VirtualHost>

and configuration check issues warnings :

AH00112: Warning: DocumentRoot [/home/admin/domains/netwerkspel.nl/public_html/ai/public/ai] does not exist
AH00112: Warning: DocumentRoot [/home/admin/domains/netwerkspel.nl/public_html/ai/public/ai] does not exist
AH00112: Warning: DocumentRoot [/home/admin/domains/netwerkspel.nl/public_html/avn/public/avn] does not exist
AH00112: Warning: DocumentRoot [/home/admin/domains/netwerkspel.nl/public_html/avn/public/avn] does not exist

Can anyone see why all of a sudden the SUB itself is added at then of the paths? I indicated with arrows in the code above..

How I turn this back so they point to the right rootdirectories?

M.Koops
  • 145
  • 1
  • 15
  • Ok, I hate to say it, but they f*cked up. Is there a way you can move files to other directories? `/home/admin/domains/` is your base. I end then ace all your subdomains and your www there. After that, adjust your apache config file. See if they can do it, they caused it – UnderDog Dec 20 '22 at 18:59
  • Do you know if these things happen more often? Is it a settingin DirectAdmin? – M.Koops Dec 20 '22 at 20:49
  • @UnderDog what do you mean by " I end then ace all your subdomains and your www there"? – M.Koops Dec 20 '22 at 22:12
  • Typos, mobile. I meant: *Move* all your subdomains there – UnderDog Dec 21 '22 at 01:49
  • All domains are there, eg '/home/admin/domains/netwerkspel.nl/public_html/demo/public' but the .conf adds another demo at the end. The index.php is in ' /demo/public ' not in 'demo/public/demo' – M.Koops Dec 21 '22 at 08:08

1 Answers1

0

Solved problem. Problem was with the Templates.

In DirectAdmin -> Custom HTTPD Configurations you click the domainname and then, right under the list of available Tokens you can watch the "Templates". These appear to be the templates that DirectAdmin uses when constructing the httpd.conf with the virtualhosts as defined by you.

In my case I defined

|*if SUB="demo"|
|?DOCROOT=/home/admin/domains/netwerkspel.nl/public_html/demo/public|
|*endif|

And direct Admin translated it into directories like <Directory /home/admin/domains/netwerkspel.nl/public_html/demo/public/demo>

I found that the templates responsible for the translation are:

 /usr/local/directadmin/data/templates/custom/virtual_host2_sub.conf     
 /usr/local/directadmin/data/templates/custom/virtual_host2_secure_sub.conf     

These can be edited and placed in a custom directory, to point out to DirectAdmin that these are templates to use.

First I created the custom folder ( use sudo, access denied otherwise)

mkdir -p /usr/local/directadmin/data/templates/custom/
chmod 711 /usr/local/directadmin/data/templates/custom/
chown diradmin:diradmin /usr/local/directadmin/data/templates/custom/ -R

and the copy the relevant templates into it:

sudo cp -p virtual_host2_secure_sub.conf custom
sudo cp -p virtual_host2_sub.conf custom

The next step is to edit both the templates in the custom folder. Find the line that states:

|?SDOCROOT=`DOCROOT`/'SUB'|

and change it into

|?SDOCROOT=`DOCROOT`|

Now the templates in DirectAdmin look like:

/usr/local/directadmin/data/templates/custom/virtual_host2_sub.conf     *** Custom Template ***
 /usr/local/directadmin/data/templates/custom/virtual_host2_secure_sub.conf     *** Custom Template ***

DirectAdmin will use the Custom templates. After saving the configurations again the subdomains work again!

M.Koops
  • 145
  • 1
  • 15