type
status
date
slug
summary
tags
category
icon
password
全能型 uWSGI 配置
其实 uWSGI 也可以用来直接提供静态文件,虽然相比 nginx 效率要低一些,但部署时配置起来更为方便。只需在 uWSGI 的配置文件中添加
static-map
配置项。uWSGI 配置静态文件挂载点
通过
--static-map mountpoint=path
选项,uWSGI 即可将指定请求前缀映射到文件系统上的对应物理目录。通过以上配置,如接收到一个对 /images/logo.png 的请求,并且 /var/www/img/logo.png 存在,那么 uWSGI 将会提供它。否则,uWSGI 托管的应用会管理这个请求。
uWSGI 配置路由
nginx 有时另外一个重要作用便是路由, uWSGI 在 1.9 版本后也提供了一个可编程的内部路由子系统,可以通过这个内部路由子系统来动态改变处理请求的方式。
例如将所有的
http
链接转到 https
地址下:完整配置
通过以上的选项,一个小站便可仅通过 uWSGI 部署起来了,顺便也分享下我的站点配置。
参考资料
使用uWSGI提供静态文件 https://uwsgi-docs-zh.readthedocs.io/zh_CN/latest/StaticFiles.html uWSGI内部路由 https://uwsgi-docs-zh.readthedocs.io/zh_CN/latest/InternalRouting.html