Hi I'm having a little bit of trouble with the 'redirect' method from a sinatra app. My app is running fine on port 51515 I can go to my page http://example.com but when I use redirect "/" or redirect "/anypage/whatever" the redirection uses the port on the address making it http://example.com:51515/anypage/whatever resulting of course in a 404 error. Anyone having this problem? I know of course that I could just write the full address, but this behaviour is not supposed to happen. So any help would be appreciated. asked 23 Feb '11, 17:35 Phrozen |
Ok, it seems its a Rack error, and they alredy know about it. https://github.com/rack/rack/commit/1c2715778d3753dce4d8df19e3d3cc698aed20c6 I tried to patch my Rack version (1.2.1 after making a cleanup removing 1.0.1 that comes with the installer) but there are many changes in the git version. I used the /rack/lib/rack/request.rb contents from the github version and replaced my own file in the installation. Everything seems to be working now. answered 23 Feb '11, 18:10 Phrozen |
I have already checked the problem and it is described pretty well in here: http://groups.google.com/group/rack-devel/browse_thread/thread/ab50ea3e5f06cd6
It seems when Rack is sitting behind a proxy, (example passenger in webfaction with port 51515) the redirect method sees the lack of :port in the address (http://example.com), and falls back to the proxy port (51515) instead of going on with port 80. It seems Rails have its own redirect implementation and its why it works correctly, but other rack apps will fail in these.
Anyone has a solution?