В настоящее время я пытаюсь разместить два разных Django сайта на одном AWS сервере, используя Nginx и Uwsgi emperor.
Вот мои конфигурационные файлы:
website1.ini
[uwsgi]
# django-related settings
# the base directory (full path)
project_name = backend
base_dir = /home/ubuntu/website1/
virtualenv = /home/ubuntu/website1/env
#chdir = location where manage.py is present
chdir = %(base_dir)/backend
# django's wsgi file
module = %(project_name).wsgi:application
# the virtualenv (full-path)
# process related settings
# master
master = true
# maximum number of processes
processes = 10
# the socket (use the full path to be safe)
socket = /home/ubuntu/server_files/website1socket.sock
# ... with appropriate permissions - may be needed
chmod-socket = 666
# clearn environment on exit
vacuum = true
website2.ini
[uwsgi]
# django-related settings
# the base directory (full path)
project_name = website2backend
base_dir = /home/ubuntu/website2/
virtualenv = /home/ubuntu/website2/env
#chdir = location where manage.py is present
chdir = %(base_dir)/djangoRestApi
# django's wsgi file
module = %(project_name).wsgi:application
# the virtualenv (full-path)
#:home = /home/ubuntu/website2/env
# process related settings
# master
master = true
# maximum number of processes
processes = 5
# the socket (use the full path to be safe)
socket = /home/ubuntu/server_files/website2socket.sock
# ... with appropriate permissions - may be needed
chmod-socket = 666
# clearn environment on exit
vacuum = true
emperor.ini
[uwsgi]
emperor = /home/ubuntu/server_files/vassals
uid = ubuntu
gid = ubuntu
website1.conf (/ etc / nginx / sites-available /)
upstream django {
server unix:///home/ubuntu/server_files/website1socket.sock; # for a file socket
}
# configuration of the server
server {
# the port your site will be served on
listen 8009;
# the domain name it will serve for
server_name <my server IP>; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
location /static {
alias /home/ubuntu/website1/backend/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /home/ubuntu/server_files/uwsgi_params; # the uwsgi_params file you installed
}
error_log /home/ubuntu/nginx-log.log;
}
website2.conf (/ etc / nginx / sites-available)
upstream django_two {
server unix:///home/ubuntu/server_files/website2socket.sock; # for a file socket
}
# configuration of the server
server {
# the port your site will be served on
listen 8000;
# the domain name it will serve for
server_name <my server IP>; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /path/to/your/mysite/media; # your Django project's media files - amend as required
}
location /static {
alias /home/ubuntu/website2/djangoRestApi/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django_two;
include /home/ubuntu/server_files/uwsgi_params; # the uwsgi_params file you installed
}
error_log /home/ubuntu/mpac-nginx-log.log;
}
и Мой uwsgi.service:
[Unit]
Description=uWSGI instance to serve both websites (EMPEROR)
After=network.target
[Service]
User=ubuntu
Group=ubuntu
ExecStart=/usr/local/bin/uwsgi --emperor /home/ubuntu/server_files/emperor.iniRestart=alwaysKillSignal=SIGQUIT
Type=notify
NotifyAccess=all
[Install]
WantedBy=multi-user.target
Я могу успешно запустить сервер, НО только один из сайтов может быть доступен (один на порту 8000), а другой просто возвращает
This site can’t be reached
<IP Address> took too long to respond.
Try:
Checking the connection
Checking the proxy and the firewall
Running Windows Network Diagnostics
ERR_CONNECTION_TIMED_OUT
Я что-то здесь не так делаю? Можно ли разместить оба сайта на одном IP-сервере, но на разных портах? Пожалуйста, помогите!
Заранее спасибо!