代理背后的安全表单身份验证
我们在负载均衡器上使用 Stunnel(去除 SSL)和 HAProxy - 然后通过 HTTP 将请求发送到 IIS。
我们遇到的问题是我们希望我们的站点 (ASP.NET) 以安全的方式设置 cookie - 即通过将 requireSSL 属性设置为 true。
当我们设置此属性并向站点发出 HTTPS 请求时,我们会收到此错误:
The application is configured to issue secure cookies. These cookies require the browser to issue the request over SSL (https protocol). However, the current request is not over SSL.
如果请求是通过 SSL 从负载均衡器发出的,是否可以信任 Web 服务器?或者这不是问题,因为只能通过 SSL 访问我们的网站(仅开放 443)?
We use Stunnel (to strip out SSL) and HAProxy on our Load Balancer - which then sends on requests to IIS via HTTP.
The problem we have is we want our sites (ASP.NET) to set cookies in a secure fashion - i.e. by setting the requireSSL attribute to true.
When we set this attribute and make a HTTPS request to the site, we get this error:
The application is configured to issue secure cookies. These cookies require the browser to issue the request over SSL (https protocol). However, the current request is not over SSL.
Is it possible to trust the webserver if the the request is coming over SSL from the load balancer? Or is this a non-problem as it is ONLY possible to access our site via SSL (only 443 is open)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于 ASP.NET MVC 3 用户(我们就是这样),您还可以使用我放在一起的以下 GlobalFilter 来处理此问题,然后它可以保护发回的任何 cookie:-
这将在任何 cookie 上设置 HTTPOnly 标志,然后如果请求来自非本地源,它也会设置安全标志。这允许我们通过 HTTP 而不是 HTTPS 进行本地调试(但如果您所做的一切都是通过 HTTPS 进行的,则可以简单地删除此检查)。
For ASP.NET MVC 3 users - which we are, you can also handle this with the following GlobalFilter that I've put together - which can then secure any cookie sent back:-
This will set the HTTPOnly flag on any cookie regardless, then if the request is from a non-local source it will also set the secure flag. This allows for us to do local debugging over HTTP rather than HTTPS (but you can simply remove this check if everything you do is over HTTPS).
而不是这个:
尝试这个:
如果您使用 ASP.NET MVC,您还可以使用全局操作过滤器,它在响应中的所有 cookie 上设置安全标志
Instead of this:
try this:
If you are using ASP.NET MVC, you could also use a global action filter which sets the secure flag on all cookies in the response