Vis*_*hal 13 ruby-on-rails passenger nginx amazon-web-services elastic-load-balancer
我在我的应用程序中使用了独立乘客.目前我的应用程序在http和https上运行.我想将所有http请求重定向到https.我在我的应用程序中使用了负载均衡器.我读过这篇文章
https://aws.amazon.com/premiumsupport/knowledge-center/redirect-http-https-elb/
https://www.phusionpassenger.com/library/config/standalone/intro.html#nginx-configuration-template
我尝试了这两种方法
1)
if ($http_x_forwarded_proto = "http") {
return 301 https://$host$request_uri;
}
Run Code Online (Sandbox Code Playgroud)
2)
if ($http_x_forwarded_proto != "https") {
rewrite ^(.*)$ https://$server_name$REQUEST_URI permanent;
}
Run Code Online (Sandbox Code Playgroud)
我以同样的方式尝试了所有过程.但每次进入无限循环时,在我开始乘客之前,实例会因为请求超时太多而终止自身并创建新实例.
我无法弄清楚,无论是弹性负载平衡器还是乘客配置问题.我想当我停止乘客和用户尝试访问应用程序.生成请求超时以及由于创建了新实例.我不确定.
提前致谢 :)
您可以在代理级别或应用程序级别执行此操作。要在应用程序级别执行此操作:
# config/environments/production.rb
...
config.force_ssl = true
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
636 次 |
| 最近记录: |