我有一个基本的html站点在域上运行(比如 example.com),我想在子目录中运行一个烧瓶应用程序(例如:example.com/test)Flask 应用正在使用默认 Flask 开发服务器在端口 5433 上运行。
我使用以下nginx配置来实现这一点
location /test {
rewrite /test(.*) $1 break;
proxy_pass http://localhost:5433;
proxy_redirect default;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /static/{
alias /home/hrishi/www/example.com/test/app/static/;
}
我可以使用 example.com/test/url 访问该应用程序,但尽管有别名,但静态文件无法加载(给出 404 错误)。
我该如何解决这个问题?
这是因为有一个额外的
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
expires max;
}
在服务器块内,我删除了它并更改了静态目录的权限
chmod -R 664 /the/path/to/static/dir
chmod a+X /the/path/to/static/dir
它就像一个魅力