Run unlimited experiments on 1 single Digital Ocean droplet with Nginx, Gunicorn and Django.

I am using ‘ Django One Click Image ’ to create a new droplet on Digital Ocean.

The process of creating new droplet, generate new Django project for each experiment and point to different domain name can be done 100% programmatically. However for speed and simplicity, some of the steps is manually for now. Comment if you think i should build an automated tool to “Create New Experiment on one Digital Ocean Droplet”.

We then need to open up the server blog config file in a text editor. You can use Nano or VIM.

$ vim /etc/nginx/sites-available/experiment1.com

Without the comment line, the file should look similar to this

If we look at the listen directives on line 6 and 7, only one of our server block can have the default_server spec. This specifies which block should server a request if the server_namedoes not match any of available server block.

Visit your domain name provider and config A and AAAA record to point to ipv4 and ipv6 address of your Digital Ocean droplet.

It will take couple minutes to couple hours for our domain name provider to update your new record.

You can also test it locally in your laptop by editing your hosts file in your local machine.

$ sudo nano /etc/hosts

Add following line with ???.???.???.??? is your Digital Ocean IP address and open expriment.com or www.experiment1.com in any browsers. The browsers will forward your to the DO ip and Nginx shoud start serving your experiment app content.