我希望这是在这里而不是服务器故障,因为我认为它更像是夹层/ django问题。
我开始使用gunicorn -b 127.0.0.1:8000 -b 127.0.0.1:8001 domain1_domain2.wsgi:application
为每个主题/域绑定2个端口。
settings.py
ALLOWED_HOSTS = [
'domain1.dev',
'domain2.dev.',
"127.0.0.1:8000",
"127.0.0.1:8001",
"*",
]
HOST_THEMES = [
('domain1.dev', 'theme1'),
('domain2.dev', 'theme2'),
('127.0.0.1:8000', 'theme1'),
('127.0.0.1:8001', 'theme2'),
]
nginx的
server {
listen 80;
server_name domain1.dev;
location /static {
root /home/david/domain1_domain2/domain1_domain2/domain1;
}
location / {
include proxy_params;
proxy_pass http://127.0.0.1:8000;
}
}
server {
listen 80;
server_name domain2.dev;
location /static {
root /home/david/domain1_domain2/domain1_domain2/domain2;
}
location / {
include proxy_params;
proxy_pass http://127.0.0.1:8001;
}
}
主机
127.0.0.1 www.domain1.dev
127.0.0.1 domain1.dev
127.0.0.1 www.domain2.dev
127.0.0.1 domain2.dev
mezzanines multi tenancy / www.domain1.dev正确显示theme1。但是http://127.0.0.1:8000 / www.domain2.dev也会显示theme1,而不是预期的主题2。
这可以用多租户来完成吗?我做错了什么?谢谢!