我已经关注了uwsgi的一个片段,试图启用hsts。这是我目前的配置:
[uwsgi]
http-socket = :$(PORT)
master = true
processes = 4
die-on-term = true
module = webapp:app
memory-report = true
check-static = %v/webapp/static/
route= ^/?$ static:%v/webapp/static/pages/index.html
route-host = ^localhost:(?:[0-9]+)$ last:
route-if-not = equal:${HTTPS};on redirect-permanent:https://${HTTP_HOST}${REQUEST_URI}
route-if = equal:${HTTPS};on addheader:Strict-Transport-Security: max-age=31536000
route = .* last:
我要做的是强制执行除localhost之外的任何事情。该站点适用于localhost,但在heroku上,对主页的请求根本没有被重定向,对静态资产的请求进入无限循环,即使https请求被重定向也是如此。
问题是Heroku的负载均衡器没有安全连接到dyno。有没有办法根据X-Forwarded-Proto
标题进行路由,或者基于包含协议的完整请求网址(因此我可以将其与^https:
匹配)?
答案 0 :(得分:0)
这对我有用:
DECLARE @d varchar(10)
set @d='2015/12/11'
select
SUBSTRING(@d, 6, charindex('/', @d, 6) - 6) as week,
SUBSTRING(@d, charindex('/', @d, 6)+1, charindex('/', @d, len(@d) - charindex('/', @d, 6))) as day,
DateAdd(
day,
cast(SUBSTRING(@d, charindex('/', @d, 6)+1, charindex('/', @d, len(@d) - charindex('/', @d, 6))) as int),
DateADD(
week,
cast(SUBSTRING(@d, 6, charindex('/', @d, 6) - 6) as int),
DATEFROMPARTS(cast(SUBSTRING(@d, 0, 5) as int), 1,1)
)
) as d