I am trying to serve two Django sites using Nginx.
I can serve no problem, but if I activate both, it sends both URLs to the same site. This is my first time using Nginx, I usually use Apache, so bear with me.
I have two sites on sites that look like this:
site1.com:
server{
server_name www.site1.com;
listen 69.164.211.85:80;
access_log /var/www/site1.env/logs/access.log;
error_log /var/www/site1.env/logs/error.log;
location /static/ {
autoindex on;
alias /var/www/site1.env/Site1/static/;
}
location / {
uwsgi_pass 127.0.0.1:3031;
include uwsgi_params;
uwsgi_param UWSGI_APPID site1;
uwsgi_param UWSGI-FILE /var/www/site1.env/Site1/wsgi/site1_wsgi.py;
}
}
site2.net
server{
server_name www.site2.net;
listen 69.164.211.85:80;
access_log /var/www/site2.env/logs/access.log;
error_log /var/www/site2.env/logs/error.log;
location /static/ {
autoindex on;
alias /var/www/site2.env/Site2/static/;
}
location / {
uwsgi_pass 127.0.0.1:3032;
include uwsgi_params;
uwsgi_param UWSGI_APPID site2;
uwsgi_param UWSGI-FILE /var/www/site2.env/Site2/wsgi/site2.py;
}
}
I also run two instances of UWSGI that start with these scripts:
Site 1:
description "uWSGI server"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec /usr/local/bin/uwsgi \
-H /var/www/site1.env
Site 2:
description "uWSGI server"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec /usr/local/bin/uwsgi \
-H /var/www/sit2.env
This is what my nginx.conf file looks like:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
I would have thought that the uwsgi_pass set for different ports would prevent them from moving to the same one, but obviously I am missing something else. I would be grateful for any help, thanks!
source
share