首页 > 解决方案 > Nginx + Gunicorn + Flask 静态资产 404

问题描述

我想使用 Nginx 使 {host1}/v2 代理传递到另一个 IP。

我的 Nginx 和 Gunicorn 在不同的两台服务器上

这是我的配置:

location /v2 {
    proxy_pass http://127.0.0.1:7777/;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

我的 Gunicorn 命令:

gunicorn -b 0.0.0.0:7777 -w 1 autoapp:app

它有效,但未找到 Flask 静态响应 404。

静态网址是http://{host}/static

我该如何配置?谢谢:-)

标签: nginxflaskgunicorn

解决方案


我解决了!

{host}/v2/static能行得通。

我使用Flask-Webpack了扩展名。

所以只需配置这个参数

WEBPACK_ASSETS_URL = '/v2/static/'

推荐阅读