【发布时间】:2018-05-02 15:28:39
【问题描述】:
我无法将http://example.com 重定向到https://example.com。我尝试了各种配置,但没有任何效果。
根据研究,我意识到我需要将其添加到 nginx 配置中。
if ($http_x_forwarded_proto != 'https') {
rewrite ^ https://$host$request_uri? permanent;
}
我在 ..ebextensions 目录中新建一个配置文件,内容如下,
upstream my_app {
server unix:///var/run/puma/my_app.sock;
}
log_format healthd '$msec"$uri"'
'$status"$request_time"$upstream_response_time"'
'$http_x_forwarded_for';
server {
listen 80;
server_name _ localhost; # need to listen to localhost for worker tier
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
set $hour $4;
}
access_log /var/log/nginx/access.log main;
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;
location / {
proxy_pass http://my_app; # match the name of upstream directive which is defined above
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /assets {
alias /var/app/current/public/assets;
gzip_static on;
gzip on;
expires max;
add_header Cache-Control public;
}
location /public {
alias /var/app/current/public;
gzip_static on;
gzip on;
expires max;
add_header Cache-Control public;
}
}
保存并执行
- eb 部署
- 转到http://example.com
我仍然收到“不确定”消息。
我还使用了来自this 的内容。但这也不起作用。
我错过了什么?
苏尼尔
【问题讨论】:
标签: ruby-on-rails amazon-web-services redirect amazon-elastic-beanstalk puma