【发布时间】:2015-10-26 13:35:46
【问题描述】:
我想要以下路由行为:
-
webapp/static/中存在的任何路径都应路由到该文件 - 任何其他不以
/auth或/api开头的路径都应该路由到webapp/static/pages/index.html - 将剩余的请求路由到我的 uwsgi 应用程序。
我有以下 uWSGI 配置:
[uwsgi]
http-socket = :$(PORT)
master = true
processes = 4
die-on-term = true
module = webapp:app
memory-report = true
;HSTS
route-host = ^localhost:(?:[0-9]+)$ goto:localhost
route-if-not = equal:${HTTP_X_FORWARDED_PROTO};https redirect-permanent:https://${HTTP_HOST}${REQUEST_URI}
route-if = equal:${HTTP_X_FORWARDED_PROTO};https addheader:Strict-Transport-Security: max-age=31536000; preload
route-label = localhost
check-static = %v/webapp/static/
route = ^(/?|/(?!(auth.*|api.*))(.*))$ static:%v/webapp/static/pages/index.html
问题是最终路由规则覆盖了静态文件处理程序,即使我更改了它们的顺序。以前,我使用正则表达式 ^/?$ 仅将请求发送到 / 到索引页面,这有效完美,所以它必须与正则表达式的工作方式有关。
【问题讨论】:
标签: regex configuration routing uwsgi ini