简体   繁体   中英

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)

producing:

http://MYAPPHOST/account_activation/7Apxg0G5t2V5tHrO2tatPQ/edit?email=sdf%40oiu.com

which works when I change it to https but it isn't being redirected. I already have config.force_ssl = true so I'm not sure how to enable this redirect. Any help is appreciated.

Whenever I go to http://MYAPP I get redirected to 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).

Check your SSL settings, for your web server, particularly the X-Forwarded-Proto header. When a HTTPS request comes to Apache/NGINX, they will terminate the SSL connection and send a HTTP request to Unicorn/Puma/Thin/Webrick. Your Rails server will see protocol=HTTP unless you set the X-Forwarded-Proto header. That will cause your x_y_z_url helpers to return http://... instead of https://... .

For example, in 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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM