如何防止 Passenger Standalone/nginx 删除双斜杠?

发布于 2024-10-19 23:19:46 字数 289 浏览 4 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦言归人 2024-10-26 23:19:46

使用 /url/http://example.com 与正确 URL 的规则相冲突:

根据 RFC 1738,3.3。 HTTP:

Within the <path> and <searchpart> components, "/", ";", "?" are
reserved.  The "/" character may be used within HTTP to designate a
hierarchical structure.

我会对“http://example.com”进行编码,而不是尝试将其作为路径的一部分传递。

Using /url/http://example.com is colliding with the rules for proper URLs:

According to RFC 1738, 3.3. HTTP:

Within the <path> and <searchpart> components, "/", ";", "?" are
reserved.  The "/" character may be used within HTTP to designate a
hierarchical structure.

I would encode the 'http://example.com' rather than attempt to pass it as part of the path.

墨洒年华 2024-10-26 23:19:46

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. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文