运行 RoR 应用程序的 Nginx + Passenger 返回 401,而预期为 302

运行 RoR 应用程序的 Nginx + Passenger 返回 401,而预期为 302

我在 Nginx 上的 Passenger 上运行了一个 RoR 应用。我使用 devise 作为我的身份验证方法,并且有一个链接,该链接会通过电子邮件发送给需要身份验证才能查看的用户。

如果用户单击 Outlook 中的链接,并且 IE 是默认浏览器,则 IE 将使用以下标头发出 HTTP 请求:

GET http://www.company.com/custom_layouts/108 HTTP/1.1
Accept: */*
Accept-Language: en-us
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: www.company.com

返回:

HTTP/1.1 401 未授权内容类型:/; charset=utf-8 Transfer-Encoding: chunked 连接:keep-alive 状态:401 X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 2.2.15 WWW-Authenticate: Basic realm="Application" Cache-Control: no-cache X-UA-Compatible: IE=Edge,chrome=1 Set-Cookie: _vxwer_session=[sessionstr]; path=/; HttpOnly X-Runtime: 0.011918 服务器:nginx/0.7.67 + Phusion Passenger 2.2.15 (mod_rails/mod_rack)

31 您需要登录或注册才能继续。0

当在地址栏中输入完全相同的 URL 时,它会执行以下操作:

GET http://www.company.com/custom_layouts/108 HTTP/1.1
Accept: image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Accept-Language: en-US
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: www.company.com

返回:

HTTP/1.1 302 Found
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 302
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 2.2.15
Location: http://www.company.com/users/sign_in
Cache-Control: no-cache
X-UA-Compatible: IE=Edge,chrome=1
Set-Cookie: _xswer_session=[session_info_here]; path=/; HttpOnly
X-Runtime: 0.010798
Server: nginx/0.7.67 + Phusion Passenger 2.2.15 (mod_rails/mod_rack)

6f
<html><body>You are being <a href="http://www.company.com/users/sign_in">redirected</a>.</body></html>
0

我希望他们无论如何都能回报同样的东西。

答案1

看看下面的源代码在设计中这与 navigational_formats 有关。

我遇到了和你描述相同的问题,并且设置

config.navigational_formats = [:"*/*", :html]

在设备初始化程序中为我修复了这个问题。我还不知道为什么来自 Outlook 的 IE 请求会被传递为/

相关内容