如何限制Django的调试页面仅显示给某些IP [英] How to limit Django's debug page to display only to certain IPs

查看:476
本文介绍了如何限制Django的调试页面仅显示给某些IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将我的网站暴露在互联网上(有些东西让它不被大多数人们所困扰),但是我想确保当500(?)发生错误只能由我的局域网内的人看到;也就是说,一个已知的IP范围。

I need to expose my site to the internet (there are things keeping it from being stumbled upon by most people) but I want to make sure the debug page which appears when a 500 (?) error occurs is only seen by people inside my LAN; that is, a known IP range.

我是专门提到我的Django网站抛出的错误 - 我不需要隐藏500页,由我的网络服务器生成(例如,在Django之前发生错误)。

我查了一下,发现了我可以通过HTTP标头检查IP,或通过各种功能来获取远程IP。但是,然后出现配置调试页面的问题。

I looked into this some, and discovered I can check the IP via HTTP headers, or through various functions to get remote IP. But then there is the matter of configuring the debug pages based on such.

然而,鉴于我试图隐藏的信息的敏感性,我认为最好先问问一下,然后才能穿上任何一款似乎适合的鞋子。我认为Django已经足够成熟,有足够的用户,有一个或多个正确的方式来做到这一点,所以我要求一些输入。

However, given the sensitive nature of the information I am attempting to hide, I thought it best to ask around first before just going w/whatever shoe appears to fit first. I would think Django is mature enough and has enough users that there is one or more "right" ways to do this, so I'm asking for some input.

添加'l info:在Ubuntu上运行Django 1.3和1.4(dev),使用mod_wsgi。

Add'l info: running Django 1.3 and 1.4 (dev) on Apache with mod_wsgi on an Ubuntu box.

推荐答案

正确配置ADMINS和SMTP设置,以便将此类错误的详细信息发送给您。尝试基于配置差异的客户端IP是一个坏主意,特别是在涉及代理时。

You are better off configuring properly the ADMINS and SMTP settings so that details of such errors are sent to you in email. Trying to base configuration differences off client IP is a bad idea especially when proxies are involved.

您还可以查看 Sentry 新的遗物

这篇关于如何限制Django的调试页面仅显示给某些IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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