This project is archived and is in readonly mode.
[Rails 3] Routes redirect method bug with https
-
Andrew White
- Milestone cleared.
- State changed from new to open
- Assigned user set to Andrew White
- Importance changed from to High
I've got a test but the scheme 'https' seems to be maintained, it's just adding an unnecessary 443 port number which I know where to fix. Can you confirm that this is the case for you?
-
Thibaud Guillaume-Gentil
In my case https is not maintained and replaced by http. I can retry after you have fixed the useless 443 port addition, if you want. Thanks
-
Andrew White
How are you testing it?
-
Andrew White
The attached patch fixes the port number issue. I can't see how the scheme wouldn't be maintained since the redirect code reads it from the current request.
-
Thibaud Guillaume-Gentil
I don't test it, it's how it "work" on my staging Heroku env. Maybe it's an issue related to Heroku nginx config with the 443 port. I'll try with your patch tomorrow.
-
Thibaud Guillaume-Gentil
With your patch the 443 port is properly removed but https is still replaced by http.
I have apply your patch on edge rails (http://github.com/thibaudgg/rails/tree/routes_patched) and make a little app (deployed on Heroku with SSL add-on (heroku addons:add ssl:piggyback)) to show you the https problem.The little app: http://github.com/thibaudgg/https_app
Heroku deploy: https://https-app.heroku.com (redirected to http://https-app.heroku.com/hello)Hope it'll help!
-
Andrew White
Looks as though the problem is in Rack rather than Rails. Looking at the source code for the various handlers not all of them set the rack.url_scheme environment variable correctly. There's already a workaround for request.ssl? which will work here as heroku sets HTTP_X_FORWARDED_PROTO to https if the incoming request is ssl.
The attached combined patch should fix it.
-
Thibaud Guillaume-Gentil
Great, our second patch fix the problem.
https://https-app.heroku.com => https://https-app.heroku.com/hello
Thanks a lot Andrew and have a nice week-end.
-
Repository
- State changed from open to resolved
(from [47280f083a06dfd034f2e1a2661adf02b0e3a064]) Don't add the standard https port when using redirect in routes.rb and ensure that request.scheme returns https when using a reverse proxy.
[#5408 [Rails 3] Routes redirect method bug with https state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/47280f083a06dfd034f2e1a2661adf... -
Repository
(from [0d0fbf1e648606c9499e332bad412da005a4e37f]) Don't add the standard https port when using redirect in routes.rb and ensure that request.scheme returns https when using a reverse proxy.
[#5408 [Rails 3] Routes redirect method bug with https state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/0d0fbf1e648606c9499e332bad412d... -
blair.silverberg
I am still encountering this problem on heroku. When navigating to https://secure.ignitiontutoring.com user is redirected to http://secure.ignitiontutoring.com.
-
Andrew White
Blair, you'll need to give me more to work with than that - for example a dump of the request environment that your app receives, some relevant routes and whether you're using any plugins, gems or middleware that performs ssl redirects like ssl_requirement or rack-ssl-enforcer.
-
mdrozdziel
Looks like I am getting this error too. I am using rack-ssl-enforcer with :strict => true. Every https:// request (which should be enforced to http://), and is beeing redirected inside the controller ends up beeing redirected to http://https://
-
mdrozdziel
I am very sorry, but this is probably not related to the previous bug. I read Blair's report, and immediately though that this is the case. I even created a demo app, but it turned out it works in on a clean up. I found that url_for help was returning http://https://.. paths. This is probably more related to translate_routes gem, than rack-ssl-enforcer.
In case someone runs into this issue and ends up here from Google: I solved this for just by adding :path_only => true to the url_for helpers. Now everything is ok.
