如何使用密码保护gunicorn上托管的网站
有没有办法对gunicorn中托管的应用程序进行密码保护,
我在apache中使用.htaccess做到了这一点,但是我们可以在gurnicorn中做到这一点吗?
Is there a way to password protect an application which is hosted in gunicorn,
I did this with .htaccess in apache, but can we do this in gurnicorn?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还可以使用中间件,例如终止每个会话,如果不符合要求则不显示任何内容。例如,您可以定义中间件来检查请求是否来自您使用的 IP,如果是 - 不执行任何操作,如果否 - 停止。也许不是最好的,但解决方案:)
You can also use middleware and for example kill every session and show nothing if it not passes the requirements. For example, you can define middleware which checks if the request comes from the IP you use, if yes - do nothing, if no - stop. Maybe not the best, but solution :)
您标记了 django 并且它有一些正确构建的有用的东西进入它......
你应该能够做一个 @login_required 就在您的特定视图功能之前。
如果当前的“匿名”用户未登录,这将强制他们进入登录屏幕。
You tagged django and it has some useful things built right into it...
You should be able to do a @login_required right before your specific view funciton.
This will force the current 'anonymous' user to a login screen if they aren't logged in.