如何使用 uWSGI 内部路由将 HTTP 重定向到 HTTPS? [英] How can I redirect HTTP to HTTPS with uWSGI internal routing?

查看:43
本文介绍了如何使用 uWSGI 内部路由将 HTTP 重定向到 HTTPS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 uWSGI 部署了一个 WSGI 应用程序,但是我没有使用 NGINX.我如何使用 uWSGI 的内部路由 来重定向 http 请求 https?

I have deployed a WSGI application with uWSGI, but I am not using NGINX. How can I use uWSGI's internal routing to redirect http requests to https?

我尝试了 uwsgi --route-uri="^http:\/\/(.+)$ redirect-permanent:https://\$1" 但是从 uWSGI 得到一个错误: unrecognized option '--route-uri=^https:\/\/(.+)$ redirect-permanent:https://\$1'

I have tried uwsgi --route-uri="^http:\/\/(.+)$ redirect-permanent:https://\$1" but get an error from uWSGI: unrecognized option '--route-uri=^https:\/\/(.+)$ redirect-permanent:https://\$1'

推荐答案

将 http 重定向到 https,使用以下配置:

to redirect http to https, use following config:

[uwsgi]
; privileged port can only be opened as shared socket
shared-socket = 0.0.0.0:80
shared-socket = 0.0.0.0:443

;enable redirect to https
http-to-https = =0

; enable https, spdy is optional
https2 = addr==1,cert=server.crt,key=server.key,spdy=1
; alternative
; https = =1,server.crt,server.key

; force change of user after binding to ports as root
uid = user
gid = usergroup

; where original app will be running on IP or UNIX socket
socket = 127.0.0.1:8001

module = smthg.wsgi

这篇关于如何使用 uWSGI 内部路由将 HTTP 重定向到 HTTPS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆