作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我将乘客独立用于我的应用程序。目前我的应用程序同时在 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
if ($http_x_forwarded_proto = "http") {
return 301 https://$host$request_uri;
}
if ($http_x_forwarded_proto != "https") {
rewrite ^(.*)$ https://$server_name$REQUEST_URI permanent;
}
最佳答案
我希望您的所有证书都安装正确并指向正确的路径。如果没有检查以下配置
乘客.json
{
"environment": "production",
"instance_registry_dir": "/var/run/passenger-instreg",
"daemonize": true,
"user": "myappuser",
"port": 443,
"ssl": true,
"ssl_certificate": "/path/to/ssl_cert.pem",
"ssl_certificate_key": "/path/to/ssl_key.pem",
"nginx_config_template": "/path/to/nginx.conf.erb"
}
http {
server_tokens off;
server {
listen 80 default_server;
listen [::]:80 default_server;
# Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.
return 301 https://$host$request_uri;
}
关于ruby-on-rails - 如何使用 aws 弹性负载均衡器将 http 请求强制重定向到旅客独立中的 https?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47221383/
我是一名优秀的程序员,十分优秀!