为什么ActionDispatch :: Request.original_url返回错误的方案?

时间:2015-07-01 20:36:27

标签: ruby-on-rails ssl nginx unicorn

我有一个Ruby on Rails应用程序,它在模板中有以下内容......

<form action="<%= request.original_url %>" method="post">

当我通过https请求该页面时,我最终得到的表单操作与原始请求的网址完全相同,但是https://生成的结果与http://不同,导致混合内容错误。

我错过了什么?在什么情况下request.original_url会返回错误的方案?

我使用Unicorn和nginx运行Ruby on Rails。

2 个答案:

答案 0 :(得分:8)

看起来这可能是解决问题的方法:

http://blog.seancarpenter.net/2013/09/02/rails-ssl-route-generation-with-nginx-and-unicorn/

因为该站点在nginx中运行,所以nginx正在终止SSL,并且Rails不知道是这种情况。

要将此信息传递给Rails,需要设置nginx配置,以便在将请求转发到应用服务器时添加I have tried few VBA codes but none of them worked the way I want. **1st VBA code**: following code works to hide multiple rows but all at once not one at a time. If ToggleButton1.Value = True Then 'This area contains the things you want to happen 'when the toggle button is not depressed Rows(4).EntireRow.Hidden = True Rows(5).EntireRow.Hidden = True Rows(6).EntireRow.Hidden = True Else 'This area contains the things you want to happen 'when the toggle button is depressed Rows(4).EntireRow.Hidden = False Rows(5).EntireRow.Hidden = False Rows(6).EntireRow.Hidden = False End If 2nd VBA code: Hide and unhides just one row. If ToggleButton1.Value = True Then 'This area contains the things you want to happen 'when the toggle button is not depressed Rows(4).EntireRow.Hidden = True Else 'This area contains the things you want to happen 'when the toggle button is depressed Rows(4).EntireRow.Hidden = False End If Someone please help! 标头。

上面文章中的示例配置显示了......

X-Forwarded-Proto https

答案 1 :(得分:0)

您可以像这样删除 http 部分 request.original_url[4...-1] 它也将删除最后一个字符,但无论如何你都不需要最后一个反斜杠。

然后通过写作获得你的https:// "https#{request.original_url[4...-1]}" 如果你需要结束反斜杠,只需添加它。