2017-05-15 40 views
0

我想設置一個django服務器,我想要admin.example.com/app_name中的管理頁面,api.example.com/app_name中的api端點以及www.example.com/app_name中的常規頁面。我試圖通過nginx來做到這一點,但內部鏈接搞砸了,我有重定向。是我在django甚至可能嘗試?多個服務器中的Django

回答

0

這是快速和骯髒的nginx的設置,將處理所有我想

的要求,如果它不工作讓我知道從/var/log/nginx/error.log錯誤和access.log裏

upstream django { 
    server 127.0.0.1:9001; 
} 
#main server 
server { 
    location /admin { 
    deny all; 
    } 
    location /static { 
     alias /var/www/static; 
    } 
location/{ 
     uwsgi_pass django; 
     include   uwsgi_params; # the uwsgi_params file you installed 
    } 
} 
#your api server 
server { 
server api.example.com 
    location /admin { 
    deny all; 
    } 
     location /static { 
     alias /var/www/static; 
    } 
location/{ 
     uwsgi_pass django; 
     include   uwsgi_params; # the uwsgi_params file you installed 
    } 
} 
server { 
    server_name admin.example.com; 
    location /static { 
     alias /var/www/static; 
    } 
    location /admin { 
     uwsgi_pass django; 
     include   uwsgi_params; # the uwsgi_params file you installed 
    } 
    location/{ 
    deny all; 
    } 
}