Subdomain with other droplet (Ubuntu+ Nginx)

October 11, 2014 1.4k views

I suggest me what are I should to learn
I need to create 1 droplet for domain mydomain.com
Then I need to have server1.mydomain.com which is use other droplet (different ip) like this on ubuntu 14.04 and nginx server.


3 Answers

You shouldn't have to use two separate Droplets. You would just use multiple server blocks in your configuration.

server {
  server_name mydomain.com;
  access_log logs/mydomain.access.log main; 

  root /var/www/mydomain.com/htdocs;

server {
  server_name server1.mydomain.com;
  access_log  logs/server1.mydomain.access.log main;

  root /var/www/server1.mydomain.com/htdocs;
  • Hi jbradach, Thank you for your answer but I need to use 1 droplet for 1 service.
    I have 2 service to serve.

    Can you advice me for this ?

I need to use 1 droplet for 1 service.
I have 2 service to serve.

Create two Ubuntu 14.04 droplets, follow How To Install Linux, nginx, MySQL, PHP (LEMP) stack on Ubuntu 14.04 | DigitalOcean on both, and then set up your DNS records accordingly: How To Set Up a Host Name with DigitalOcean | DigitalOcean.

Your DNS records should look like this:

@          A first droplet's IP address
server1 A second droplet's IP address
by Etel Sverdlov
This article walks you through setting up the DNS for your site. The tutorial includes steps to set up an A records, point your nameservers, and provides some information about MX records.
Have another answer? Share your knowledge.