Rails 中的 SSL 网站将我转发到带有端口 443 后缀的 URL
首先,这是我的第一个 SSL Web 应用程序,因此我可能会做一些严重错误的事情。 我们在 https://bla.be/ 上针对来自客户端的请求启用了 SSL,
它似乎开箱即用。我们订购了带有 SSL 的网络托管,并且似乎不需要进行任何配置。
然而,出现了 2 个问题:
- 每当我单击某些链接(对于哪些链接来说,似乎确实是随机的)时,它会将 url 前缀从 HTTPS 变形为 HTTP,并在域名末尾添加端口 :443 后缀。导致链接失效。 (例如:https://bla.com/view/3 变为 http://bla.com:443/view/3)
它总是这样做当我通过 sendfile 下载文件时:
send_file datafile.document.path, :type => datafile.document_content_type,:处置=> '附件', :x_sendfile => true
我尝试添加 :secure =>链接确实如此,但这似乎没有做任何事情。
我是否忘记了一些必需的配置?还是我的主机设置错误?
提前致谢。
First off, this is my first SSL web application so I might be doing something horribly wrong.
We turned on SSL per request from a client on https://bla.be/
It seemed to work out of the box. We ordered web hosting with SSL and we didn't seem to have to do any configuration.
However 2 problems arose:
- Whenever I click certain links (and it really seems random as to which ones) it deforms the url prefix from HTTPS to HTTP and adds a port :443 suffix at the end of the domain name. Resulting in links that do not work. (ex.: https://bla.com/view/3 becomes http://bla.com:443/view/3)
It always does this when I download a file through sendfile:
send_file datafile.document.path, :type => datafile.document_content_type, :disposition => 'attachment', :x_sendfile => true
I tried adding :secure => true to links but that doesn't seem to do anything.
Am I forgetting some required configuration? Or is my host's setup wrong?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来您在 URL 生成中指定了 :port 选项而不是 :protocol。您想要切换到 https 协议,而不是指定 SSL 端口。
如果您为此使用库/gem,则它无法正常工作。
我推荐 ssl_requirement 插件。
It sounds like you're specifying the :port option on your URL generation instead of the :protocol. You want to switch to the https protocol, not specify the SSL port.
If you're using a library/gem for this, it's not working correctly.
I'd recommend the ssl_requirement plugin.
您是否为您的网址使用了正确的帮助方法?
我有一个类似的问题,我通过将 blabla_url 更改为 blabla_path 解决了它。
Are you using the correct help-method for your url's?
I had a similar problem and I solved it by changing the blabla_url to blabla_path.