[英]Rails - Account Activation not redirecting to https
I have my mailer sending an account activation link like the one below: 我的邮件发送者发送了一个帐户激活链接,如下所示:
edit_account_activation_url(@user.activation_token, email: @user.email) edit_account_activation_url(@ user.activation_token,电子邮件:@ user.email)
producing: 生产:
http://MYAPPHOST/account_activation/7Apxg0G5t2V5tHrO2tatPQ/edit?email=sdf%40oiu.com http:// MYAPPHOST / account_activation / 7Apxg0G5t2V5tHrO2tatPQ / edit?email = sdf%40oiu.com
which works when I change it to https but it isn't being redirected. 当我将其更改为https时,它可以工作,但没有被重定向。 I already have config.force_ssl = true so I'm not sure how to enable this redirect. 我已经有config.force_ssl = true,所以我不确定如何启用此重定向。 Any help is appreciated. 任何帮助表示赞赏。
Whenever I go to http://MYAPP I get redirected to about:blank 每当我访问http:// MYAPP时,我都会重定向到about:blank
I'm assuming this is in your production environment? 我假设这是在您的生产环境中? What hosting provider and/or server are you using (Heroku, AWS, and Apache, NGINX, etc). 您正在使用哪种托管服务提供商和/或服务器(Heroku,AWS和Apache,NGINX等)。
Check your SSL settings, for your web server, particularly the X-Forwarded-Proto
header. 检查您的Web服务器的SSL设置,尤其是X-Forwarded-Proto
标头。 When a HTTPS request comes to Apache/NGINX, they will terminate the SSL connection and send a HTTP request to Unicorn/Puma/Thin/Webrick. 当HTTPS请求到达Apache / NGINX时,它们将终止SSL连接,并将HTTP请求发送到Unicorn / Puma / Thin / Webrick。 Your Rails server will see protocol=HTTP
unless you set the X-Forwarded-Proto
header. 除非您设置X-Forwarded-Proto
标头,否则您的Rails服务器将看到protocol=HTTP
。 That will cause your x_y_z_url
helpers to return http://...
instead of https://...
. 这将导致您的x_y_z_url
帮助器返回http://...
而不是https://...
For example, in NGINX: 例如,在NGINX中:
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.