简体   繁体   English

Rails-帐户激活未重定向到https

[英]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.

相关问题 Rails ActiveStorage / Cloudinary 未将图像请求重定向到 HTTPS - Rails ActiveStorage / Cloudinary Not Redirecting Image Request to HTTPS Rails应用程序(localhost)自动重定向到HTTPS - Rails application (localhost) automatically redirecting to HTTPS 重定向到HTTPS时在Rails中进行多次重定向 - Multiple redirects in rails when redirecting to HTTPS Rails redirect_to重定向到https:// subdomain - Rails redirect_to is redirecting to https://subdomain 如何在Ruby on Rails Web应用程序中验证是否发送了帐户激活电子邮件 - How to verify if an account activation email was sent or not in Ruby on Rails web application 如何在Rails / Cloud 9 IDE中安全地生成帐户激活链接 - How to safely generate account activation links in Rails / cloud 9 ide Rails 5.1 Mailer错误-模板中的帐户激活参数 - Rails 5.1 mailer error - account activation parameter in templates 为什么在Rails邮件程序中为帐户激活电子邮件使用“编辑” URL? - Why use an “edit” url for an account activation email in a rails mailer? Rails redirect_to是从https(正确)重定向到http(不正确)? - Rails redirect_to is redirecting from https (correct) to http (incorrect)? 我的Rails应用正在生产模式下从http自动重定向到https - My rails app is auto redirecting to https from http in production mode
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM