0

I have two domains, I own both. domain1.com and domain2.com

on domain2.com I have a subdomain my.domain2.com which has an A DNS pointing to an nginx.

I want other.domain1.com to view content from my.domain2.com without redirection.

What I did is to setup a CNAME from other.domain1.com to my.domain2.com But when I enter visit it it redirects to my.domain2.com instead of showing me the content.

Is this from DNS settings or nginx should be setup differently?

  • You need to show what curl -v http://other.domain1.com shows. Also the nginx logfile output is useful in determining what causes the behavior. – Tero Kilkanen Jul 19 '15 at 12:32
1

To serve the same content out of 2 (sub)domains just set multiple server blocks:

server {
  server_name other.domain1.com
  location / {
    root /var/www/wordpress;
  }
}

server {
  server_name my.domain2.com
  location / {
    root /var/www/wordpress;
  }
}

CNAMEs are not required, you can have two domains A record point to the same IP address.

  • acutally it worked with CNAME. It doesn't make sense to add server blocks, as I let clients setup this CNAME in order to use subdomain content as whitelabel. – Alexandru R Jul 20 '15 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.