以vue框架為例,在nginx.conf中監聽80或443埠的server的路由配置設定為:
include /etc/nginx/uwsgi_params;
uwsgi_pass 127.0.0.1:8077;
include /etc/nginx/mime.types;
}
location ^~ /static { # 後端的資原始檔夾為static,前端請求後端專案包內的靜態檔案
root /root/backend_end_project/static/;
location ^~ /admin { # django的後臺管理頁面透過uwsgi轉交給django處理
location ^~ /assets { # 前端的資原始檔夾為assets,前端請求前端專案包內的靜態檔案
root /root/front_end_project/dist;
location / { # 表示其它路徑都交給前端專案根目錄下的index.html處理
root /root/front_end_project;
try_files $uri /index.html;
以vue框架為例,在nginx.conf中監聽80或443埠的server的路由配置設定為:
include /etc/nginx/uwsgi_params;
uwsgi_pass 127.0.0.1:8077;
include /etc/nginx/mime.types;
}
location ^~ /static { # 後端的資原始檔夾為static,前端請求後端專案包內的靜態檔案
root /root/backend_end_project/static/;
}
location ^~ /admin { # django的後臺管理頁面透過uwsgi轉交給django處理
include /etc/nginx/uwsgi_params;
uwsgi_pass 127.0.0.1:8077;
include /etc/nginx/mime.types;
}
location ^~ /assets { # 前端的資原始檔夾為assets,前端請求前端專案包內的靜態檔案
root /root/front_end_project/dist;
}
location / { # 表示其它路徑都交給前端專案根目錄下的index.html處理
root /root/front_end_project;
try_files $uri /index.html;
}