You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:Nginx无法为部署在子路径的Vue静态站点提供服务

求助:Nginx无法为部署在子路径的Vue静态站点提供服务

各位好,我现在碰到一个Nginx配置的问题,想请大家帮忙出出主意。

我手里有两个应用:

  • 一个是Django后端项目,文件存放在/home/founders/founders/back,目前已经正常运行在founderslooking.com域名下
  • 另一个是Vue前端项目,构建后的静态文件目录是/home/founders/founders/dist,我希望它能通过founderslooking.com/app这个子路径访问

下面是我当前配置的Django站点Nginx配置文件(之前配置到一半没写完),现在不知道该怎么调整才能让Vue站点在指定子路径正常提供服务:

upstream founders_app_server {
        server unix:/home/founders/founders/run/gunicorn.sock fail_timeout=0;
}

server {
        listen 80;
        server_name founderslooking.com default_server;

        client_max_body_size 4G;

        location / {
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

                proxy_set_header Host $http_host;

                proxy_redirect off;

                if (!-f $request_filename) {
                        proxy_pass http://founders_app_server;
                        break;
                }
        }
}

我之前试着加过针对/app路径的location配置,但要么是Vue的静态资源加载404,要么直接跳转到Django的页面,折腾了好久都没搞定,麻烦各位大佬指点下正确的配置方式,谢谢!

备注:内容来源于stack exchange,提问作者SnowCrest Digital

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.17 09:09:51