![](/img/trans.png)
[英]Django console email backend in production with gunicorn and nginx
[英]How to host 2 Django Application using gunicorn & nginx in Production
您好,我想使用 Gunicorn 和 Nginx 托管 2 個 djagno 網站,但我不知道該怎么做,這是我第一次在一個服務器和 2 個域中托管 2 個 django 網站,所以請告訴我如何托管 2 個 django 網站。 這是我位於 /var/www/site1 的 1 個文件,這是我的 2 個文件 /var/www/site2
假設您在端口 8081 和 8082 上運行您的 gunicorn 實例,您有兩個選擇:
要使用子域與 NGINX 進行反向代理,請參閱此答案。
http://site1.example.com/重定向到站點 1, http: //site2.example.com/重定向到站點 2。
NGINX 配置:
server {
listen 80;
server_name site1.example.com;
location / {
proxy_pass http://127.0.0.1:8082;
}
}
server {
listen 80;
server_name site2.example.com;
location / {
proxy_pass http://127.0.0.1:8082;
}
}
http://example.com/site1/現在重定向到站點 1,將http://example.com/site2/重定向到站點 2。
NGINX 配置:
server {
listen 80;
server_name example.com;
location /site1/ {
proxy_pass http://127.0.0.1:8081;
}
location /site2/ {
proxy_pass http://127.0.0.1:8082;
}
}
您也可以像選項 1 一樣為不同的站點使用不同的域。
http://site1.com/重定向到站點 1, http: //site2.com/重定向到站點 2。
NGINX 配置:
server {
listen 80;
server_name site1.com;
location / {
proxy_pass http://127.0.0.1:8082;
}
}
server {
listen 80;
server_name site2.com;
location / {
proxy_pass http://127.0.0.1:8082;
}
}
注意:這些是最低限度的設置,可能需要額外的配置才能使用您的特定服務。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.