Reputation: 95
I'm trying to run two django projects using nginx using these two configurations:
upstream django_project_1 {
server unix:///home/project_1_user/project_1/project_1.sock;
}
server {
listen 80;
server_name project1.com www.project1.com;
charset utf-8;
client_max_body_size 75M;
location /media {
alias /home/project_1_user/project_1/media;
}
location /static {
alias /home/project_1_user/project_1/static;
}
location / {
uwsgi_pass django_project_1;
include /home/project_1_user/project_1/uwsgi_params;
}
}
upstream django_project_2 {
server unix:///home/project_2_user/project_2/project_2.sock;
}
server {
listen 80;
server_name project2.com www.project2.com;
charset utf-8;
client_max_body_size 75M;
location /media {
alias /home/project_2_user/project_2/media;
}
location /static {
alias /home/project_2_user/project_2/static;
}
location / {
uwsgi_pass django_project_2;
include /home/project_2_user/project_2/uwsgi_params;
}
}
I run uwsgi --socket project_1.sock --module project_1.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?
Upvotes: 0
Views: 22
Reputation: 14311
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?
Upvotes: 1