One domain is redirected to another domain when using cloudflare
I am getting strange issues and have been wandering for hours and hours. I will try to be as descriptive s I can. Let me explain the situation in detail.
I have a Linode VPS and hosting 3 domains (let's say first.com, second.com, and third.com). The first two domains (first.com & second.com) are working fine as I have used Linode's name server ns[1234].linode.com in my domain registrar's custom nameserver settings. Note that, I have created first.com and second.com domains under the domains section (https://cloud.linode.com/domains) in Linode's dashboard.
However, the issue is with the third.com domain. The third.com domain is registered with cloudflare. I have setup the DNS section with A, AAAA and CNAME records and point to my Linodes VPS IP address. BUT, when I open the third.com website in browser, it is opening first.com website. YES, its opening first.com website.
In my server configuration, I have installed nginx and created configuration files for each domain separately. There are no redirects setting in configurations.
I have searched the whole internet but couldn't find appropriate answer that fixed my problem.
Any help would be greatly appreciated.
8 Replies
The only thing that I can suggest is to double check your nginx configuration as to where you have the doucment-root directory set for third.dom. If by accident you entered the same document-root directory as first.com, that is why you are getting that site and not third.com
I've made that mistake, so that is why I suggest it.
@acanton77
I have checked multiple times and it is correctly configured to access third domain. Here is my configuration file. Only third.com is replaced with my domain:
server {
server_name third.com www.third.com;
root /var/www/third.com;
index index.php;
location / {
try_files $uri $uri/ = 404;
#try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
Check you DNS with this site. Maybe let us know the URL so we can help?
@acanton77
The domains are:
first.com => asahieducation[dot]edu[dot]np
second.com => nepalio[dot]com
third.com => kodementor[dot]com
What I find interesting is that both asahieducation[dot]edu[dot]np and nepalio[dot]com have an IP of:
192.46.209.19 owned by Linode
but kodementor[dot]com has an IP of
172.67.162.47 owned by Cloudflare.
Go back to Cloudflare and ask them about this issue. Better yet, use Linode's nameserver. I'm sure there is something out of whack with Cloudflare.
@acanton77
The IP address is proxied and showing different. Now, I have turned off the proxy and actual IP address is shown.
However, the main concern is why is the third.com opens up the first.com website although there are not any redirections? I can paste the all three nginx congurations if you want to see.
Any lead would be greatly appreciated.
Now I'm getting a security violation:
Your connection is not private
Attackers might be trying to steal your information from kodementor.com (for example, passwords, messages, or credit cards). Learn more
And this:
This server could not prove that it is kodementor.com; its security certificate is from asahieducation.edu.np. This may be caused by a misconfiguration or an attacker intercepting your connection.
Could this be related to the problem?
Lets Encrypt certs are issued to (sub-)domains…not to IP addresses. You need to have a separate cert for each domain…even if they are served by the same IP address.
For example, my Linode serves a domain mydomain.com and a subdomain sub.mydomain.com. Each has a separate cert. Each is renewed according to its own 90-day schedule. Each virtual host configuration in my web server uses the cert appropriate to the (sub-)domain it's serving.
In your case, you would want a cert for EACH of first.com, second.com and third.com. The virtual host for each domain would serve that domain's cert.
-- sw