我在nginx服务器后面有一个flask应用程序。 Nginx处理SSL终止并重定向到https。所有http请求都被重定向。
在烧瓶中,我认为不需要了解这些内容,我有以下代码:
@bp.route('/',methods=['GET','POST'])
def index_root():
"""Assign a session tag.
"""
return redirect(url_for('main.index',tag=make_new_tag()))
@bp.route('/D/<tag>/accueil','POST'])
def index(tag):
return render_template('index.html',title='',tag=tag)
现在我有一个问题:当有人请求http://example.com/
时,nginx将他们301传送到https://www.example.com/
,这是正确的。然后将302的烧瓶重定向到http://www.example.com/D/123/accueil
,这不太好,因为nginx只会将301重定向到https://www.example.com/D/123/accueil
(这很好,但是我宁愿跳过该额外的重定向)。
这是某个地方的配置问题吗?
请注意,在开发人员中,烧瓶必须不要考虑https,这一点很重要。的确,flask根本不需要了解任何有关https的信息,这就是为什么我觉得这有点神秘。
感谢任何指针。