2 domains on the VPS - but they work only one at a time

I moved 2 domains on the VPS and they work fine, just one at a time

I need to disable one for the other to work - or I get 404

both have the same DNS records, pointing to the same VPS, their DNS records are both on Cloudflare, and they’re configured the same way on the VPS . they’ve Lets encrypt SSL, and I’ve added full SSL on Cloudflare for both.
The only difference is their site directory on the server, and I’ve changed the IP of the A record and www when moved to the VPS.

Everything works fine only if I keep one domain.
Today I shared the root psw with the engineer (Namecheap) and he said everything looks fine, but they’re unable to offer deeper support since I don’t use cPanel (I use aaPanel).

Can you please give me some clue?

Many thanks

VPS

  • CentOS 8
  • aaPanel 6.8.21
  • Apache 2.4 (same issue on Nginx 1.19)
  • DNS manager: Cloudflare

Hm, not quite sure, but this does not sound to me like an Cloudflare issue :thinking:

Rather, it could be the vhost file (Nginx) or virtualhost (Apache) is not properly configured as it cannot serve two hostnames (domains) from the same web server, on the same ports and from the same IP?

  • maybe by default, it’s returning the content from the first of alphabetical order hostnames it can get, despite the different domain name which you enter in a URL address bar?

Correct, each should have separate and it’s own (even user/group in best case scenario).

I run 10s of websites served from one server and one IP (using Nginx), all of them using Cloudflare.

Hi Fritex , thanks for your help.

I tried Nginx and Apache, got the same issue.

Currently I run Apache on the VPS; here are their respective config files.
Please let me know if you spot anything unusual

Many thanks

bluepek | original config


<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/www/wwwroot/bluepek.com"
    ServerName 745e5c8e.bluepek.com
    ServerAlias bluepek.com mail.bluepek.com
    #errorDocument 404 /404.html
    ErrorLog "/www/wwwlogs/bluepek.com-error_log"
    CustomLog "/www/wwwlogs/bluepek.com-access_log" combined
	#referenced redirect rule, if commented, the configured redirect rule will be invalid
	IncludeOptional /www/server/panel/vhost/apache/redirect/bluepek.com/*.conf

    #DENY FILES
     <Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)$>
       Order allow,deny
       Deny from all
    </Files>
    
    #PHP
    <FilesMatch \.php$>
            SetHandler "proxy:unix:/tmp/php-cgi-73.sock|fcgi://localhost"
    </FilesMatch>
    
    #PATH
    <Directory "/www/wwwroot/bluepek.com">
        SetOutputFilter DEFLATE
        Options FollowSymLinks
        AllowOverride All
        Require all granted
        DirectoryIndex index.php index.html index.htm default.php default.html default.htm
    </Directory>
</VirtualHost>


<VirtualHost *:443>
    ServerAdmin [email protected]
    DocumentRoot "/www/wwwroot/bluepek.com/"
    ServerName SSL.bluepek.com
    ServerAlias bluepek.com mail.bluepek.com 
    #errorDocument 404 /404.html
    ErrorLog "/www/wwwlogs/bluepek.com-error_log"
    CustomLog "/www/wwwlogs/bluepek.com-access_log" combined
    
    #SSL
    SSLEngine On
    SSLCertificateFile /www/server/panel/vhost/cert/bluepek.com/fullchain.pem
    SSLCertificateKeyFile /www/server/panel/vhost/cert/bluepek.com/privkey.pem
    SSLCipherSuite EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5
    SSLProtocol All -SSLv2 -SSLv3 -TLSv1
    SSLHonorCipherOrder On
    
    
    #PHP
    <FilesMatch \.php$>
            SetHandler "proxy:unix:/tmp/php-cgi-73.sock|fcgi://localhost"
    </FilesMatch>
    

    #DENY FILES
     <Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)$>
       Order allow,deny
       Deny from all
    </Files>

    #PATH
    <Directory "/www/wwwroot/bluepek.com/">
        SetOutputFilter DEFLATE
        Options FollowSymLinks
        AllowOverride All
        Require all granted
        DirectoryIndex index.php index.html index.htm default.php default.html default.htm
    </Directory>
</VirtualHost>

snapagileframework.com | config


<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/www/wwwroot/snapagileframework.com"
    ServerName 218ac146.snapagileframework.com
    ServerAlias snapagileframework.com mail.snapagileframework.com
    #errorDocument 404 /404.html
    ErrorLog "/www/wwwlogs/snapagileframework.com-error_log"
    CustomLog "/www/wwwlogs/snapagileframework.com-access_log" combined

    #DENY FILES
     <Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)$>
       Order allow,deny
       Deny from all
    </Files>
    
    #PHP
    <FilesMatch \.php$>
            SetHandler "proxy:unix:/tmp/php-cgi-73.sock|fcgi://localhost"
    </FilesMatch>
    
    #PATH
    <Directory "/www/wwwroot/snapagileframework.com">
        SetOutputFilter DEFLATE
        Options FollowSymLinks
        AllowOverride All
        Require all granted
        DirectoryIndex index.php index.html index.htm default.php default.html default.htm
    </Directory>
</VirtualHost>

<VirtualHost *:443>
    ServerAdmin [email protected]
    DocumentRoot "/www/wwwroot/snapagileframework.com/"
    ServerName SSL.snapagileframework.com
    ServerAlias snapagileframework.com mail.snapagileframework.com 
    #errorDocument 404 /404.html
    ErrorLog "/www/wwwlogs/snapagileframework.com-error_log"
    CustomLog "/www/wwwlogs/snapagileframework.com-access_log" combined
    
    #SSL
    SSLEngine On
    SSLCertificateFile /www/server/panel/vhost/cert/snapagileframework.com/fullchain.pem
    SSLCertificateKeyFile /www/server/panel/vhost/cert/snapagileframework.com/privkey.pem
    SSLCipherSuite EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5
    SSLProtocol All -SSLv2 -SSLv3 -TLSv1
    SSLHonorCipherOrder On
    
    
    #PHP
    <FilesMatch \.php$>
            SetHandler "proxy:unix:/tmp/php-cgi-73.sock|fcgi://localhost"
    </FilesMatch>
    

    #DENY FILES
     <Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)$>
       Order allow,deny
       Deny from all
    </Files>

    #PATH
    <Directory "/www/wwwroot/snapagileframework.com/">
        SetOutputFilter DEFLATE
        Options FollowSymLinks
        AllowOverride All
        Require all granted
        DirectoryIndex index.php index.html index.htm default.php default.html default.htm
    </Directory>
</VirtualHost>

I am sorry to say, but I am not familiar so much with Apache and unfortunately I am afraid that is rather a topic for StackExchange or Reddit at this point, because it is a server configuration issue and not Cloudflare related.

Maybe someone else here might have more experience and know better and reply, but I really do not know.

https://httpd.apache.org/docs/2.4/vhosts/examples.html

MAGIC !

You gave me some clue mate, thanks a lot

Finally after changing the respective config files these domains are now working together.
The error? aaPanel added the wrong subdomain name in their config files.
As you suspected , nothing to do with CFlare.

Tomorrow I’m going to switch back to Nginx , as I heard it’s faster than Apache.

Thanks

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.