如何防止 Passenger Standalone/nginx 删除双斜杠?
我正在尝试使用 Passenger Standalone 运行 Sinatra 应用程序。该应用程序在 URL 中采用这样的 URL:
get "/url/*" do |url|
"URL: #{url}"
end
显然 nginx 将连续斜杠减少到只有一个。当我调用 /url/http://example.com
时,它返回:URL: http:/example.com
。当我在没有 Passenger 的情况下运行它时,它工作得很好。
I am trying to run a Sinatra app with Passenger Standalone. The app takes a URL in the URL like this:
get "/url/*" do |url|
"URL: #{url}"
end
Apparently nginx reduces consecutive slashes to only one. When I call /url/http://example.com
it returns: URL: http:/example.com
. When I run this without Passenger in front of it, it works perfectly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
/url/http://example.com
与正确 URL 的规则相冲突:根据 RFC 1738,3.3。 HTTP:
我会对“http://example.com”进行编码,而不是尝试将其作为路径的一部分传递。
Using
/url/http://example.com
is colliding with the rules for proper URLs:According to RFC 1738, 3.3. HTTP:
I would encode the 'http://example.com' rather than attempt to pass it as part of the path.
Passenger Standalone 的 Nginx 是预先配置的,显然并不意味着可以定制。因此,我要么必须为此应用程序设置一个单独的 Nginx,并关闭 merge_slashes,要么寻找其他解决方案。我将以此为契机尝试 Thin。 :)
Passenger Standalone's Nginx comes preconfigured and apparently is not meant to be customized. So I either have to set up a separate Nginx with
merge_slashes off
for this app or find another solution. I will take this as an opportunity to try Thin. :)