Aaron Wieberg
2006-Apr-28 15:22 UTC
[Rails] Apache proxy to lighttpd leads to Rails routing error
Hello, I have an issue I am having trouble figuring out. I have a Rails app running through lighttpd which is accessed through an Apache proxy. My apache config: <location /rails/> ProxyPass http://localhost:81/ ProxyPassReverse http://localhost:81/ </location> RewriteEngine On RewriteRule ^/rails/(.*) http://localhost:81/$1 [P] So when apache sees /rails/ it sends the request over to lighty. Lighttpd config for the rails app: $HTTP["url"] =~ "^/feedback/" { server.document-root = "/var/www/webapps/feedback/public/" alias.url = ( "/feedback/" => "/var/www/webapps/feedback/public/" ) server.error-handler-404 = "/feedback/dispatch.fcgi" index-file.names = ( "index.html", "dispatch.fcgi" ) fastcgi.server = ( ".fcgi" => (( "socket" => "/tmp/feedback.fastcgi.socket", "bin-path" => "/var/www/webapps/feedback/public/dispatch.fcgi", "bin-environment" => ( "RAILS_ENV" => "development"), "min-procs" => 1, "max-procs" => 1 ))) } And then I have this in routes.rb so it can generate the right URLs: ActionController::AbstractRequest.relative_url_root = "/rails/feedback" So this all works. If I point my browser at https://rd-webdev/rails/feedback/ I get the default page from my app. But if I try to go to a URL with the controller/action specified I get a routing error. For example, using this URL: https://rd-webdev/rails/feedback/submit/product/tracker Rails says: Routing Error Recognition failed for "t/product/tracker" So it cuts off part of the url after rails gets it. So I know rails is getting it, but somewhere after that the URL is changed incorrectly. My guess as to whats happening is that Rails takes the URL it gets (which is feedback/submit/product/tracker after lighty gets it) and removes the relative_url_root (/rails/feedback) from that. feedback/submit/product/tracker -/rails/feedback =t/product/tracker Any way around this? Sorry for the long post... Thanks! Aaron -- Posted via http://www.ruby-forum.com/.
Aaron Wieberg
2006-Apr-28 19:51 UTC
[Rails] Re: Apache proxy to lighttpd leads to Rails routing error
Well, I''m not sure if there is any way to make what I did above work. So I just changed it so the path is the same for apache and lighty. so if i have this URL http://rd-webdev/rails/feedback/submit... it should work the same as http://rd-webdev:81/rails/feedback/submit... going straight to lighttpd without the proxy. So it works fine now. Aaron -- Posted via http://www.ruby-forum.com/.