Hello, I am running one droplet with nginx configured for running a wordpress installation. I bought another TLD and would like to host that domain from the same server too. I followed the DO tutorial on how to configure the second site which tells making a new directory in the www directory and I did so along with the other settings.
Now how do I configure the A record or the CNAME for the second TLD in the DO domain settings please?
Here are the basic info:
Any article or suggestion on that please? Much appreciated.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
@mcmurphy
When it comes to A and CNAME entries, you’ll point both domains’ A entries to the same IPv4 IP. The CNAME would simply point
www
to the domain so that you can use either or to access it.i.e.
Where
DROPLET_IP
is the IPv4 IP of your Droplet anddomain.com
is your domain name.When it comes to the
server
blocks, as long as the domain is pointing to the IP where you’ve setup the server block for the same domain, that should be all that’s needed.For example, if we have
domain01.com
anddomain02.com
and you’ve setup the same A/CNAME entries (as shown above), then you’d have at least two server blocks, one for each domain.domain01.conf
domain02.conf
Of course, the above won’t handle PHP files, though we can fix that easily by adding another location block under the first. That’d look like this:
I’m using TCP instead of Sockets for
fastcgi_pass
, though you can replace that as needed. So we could have the server blocks setup like:domain01.conf
domain02.conf
For SSL, things are a little different. We’d use something like this instead (for each domain):
The above allows us to redirect requests on port 80 to 443 so that everything is covered by SSL. This is a bit more detailed than what the guides cover, but I use similar in production, so I figured that’s what I’d give as an example.
The above assumes HTTP2 is enabled on your NGINX version. If it’s not, you may need to remove
http2
fromlisten
.@mcmurphy Can you post your Nginx configuration? It’ll be easier for us to help.