Can i run 2 django projects on 2 domains but on 1 ip?

I'm trying to run two django projects using nginx using these two configurations:

upstream django {
    server unix:///home/hypebeeruser/HypeBeer/HypeBeerProject/HypeBeerProject.sock;
}

# configuration of the server
server {
    server_name hypebeer.com.ua;
    charset     utf-8;
    # max upload size
    client_max_body_size 75M;
    # Django media and static files
    location /media  {
        alias /home/hypebeeruser/HypeBeer/HypeBeerProject/media;
    }
    location /static {
        alias /home/hypebeeruser/HypeBeer/HypeBeerProject/static;
    }
    # Send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include     /home/hypebeeruser/HypeBeer/HypeBeerProject/uwsgi_params;
    }
}
# the upstream component nginx needs to connect to
upstream django_tobabox {
    server unix:///home/tobabox/TobaBox/TobaBox/TobaBox.sock;
}
# configuration of the server
server {
    listen      80;
    server_name tobabox.com www.tobabox.com;
    charset     utf-8;
    # max upload size
    client_max_body_size 75M;
    # Django media and static files
    location /media  {
        alias /home/tobabox/TobaBox/TobaBox/media;
    }
    location /static {
        alias /home/tobabox/TobaBox/TobaBox/static;
    }
    # Send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django_tobabox;
        include     /home/tobabox/TobaBox/TobaBox/uwsgi_params;
    }
}

I run uwsgi --socket HypeBeerProject.sock --module HypeBeerProject.wsgi --chmod-socket=666 and it runs my first site, but the second doesn't work with the same comand (yes, i changed the names of .sock and project.wsgi). It runs normally without any errors, but i still can't connect via domain name.
Do I need to buy an additional IP or can I somehow configure it so that there are two sites and two domains on one IP?

You can run multiple domains on a single IP. In Apache, you use the VirtualHost directive. On nginx, they’re called Server Blocks. It looks like you’re most of the way there, but Digital Ocean has a good tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04

Are you certain you have A records from your DNS properly pointing to the single IP address for both domains you’re trying to host?

Back to Top