我有一个在域名运行的基本html网站(例如example.com),我想在子目录中运行一个烧瓶应用程序(例如:example.com/test) flask app使用默认的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错误),尽管别名。
我该如何解决这个问题?
答案 0 :(得分:1)
这是因为有额外的
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
它就像一个魅力