How can I host multiple websites on a droplet using Nginx

Posted June 25, 2014 8.9k views

So, I have a Django droplet and I’ve pointed a subdomain (say to the ip address of my droplet.

Then, I installed ghost on the same droplet and now I want to have load my ghost installation. I followed this tutorial but when I opened, instead of ghost, django showed up.

So, can you please help me with setting up multiple “server"s on subdomains on Nginx on a droplet?


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.

Submit an Answer
3 answers

@amin.bandali And your blog is dead? It was better if you added the ‘small gotchas’ here instead.

The key to setting up multiple websites on different domains or subdomains on the same server is setting up server_name in your server blocks. So your Ghost configuration would look something like:

server {

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header HOST $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_redirect off;

And your Django configuration would be like:

upstream app_server {
    server fail_timeout=0;

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html index.htm;

    client_max_body_size 4G;

    keepalive_timeout 5;

    # Your Django project's media files - amend as required
    location /media  {
        alias /home/django/django_project/django_project/media;

    # your Django project's static files - amend as required
    location /static {
        alias /home/django/django_project/django_project/static; 

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app_server;

And of course, remember to restart Nginx after making your changes:

sudo service nginx restart

Hello there,

You can host multiple sites (domain names) on a single droplet, this can be achieved using virtual hosts.

The process is really simple, all you need to do is to spin up the droplet via the app marketplace and then manually add the virtual hosts for the other sites.

We have an article that covers the process, which you check here:

Hope that this helps!