Ich verstehe es nicht. Ich habe versucht, eine Rails App hinter einem Apache Reverse Proxy laufen zu lassen. Ich bin mit Einhorn auf Port 8080.Rails in einem Unterverzeichnis hinter Apache Reverse Proxy
bundle exec unicorn -c config/unicorn.rb -E production -p 8080
Apache Virtual
ProxyPass /foo/ http://localhost:8080/
ProxyPassReverse /foo/ http://localhost:8080/
Diese im Grunde funktioniert. Eine Anfrage an http://domain.tld/foo/ kommt in der Rails App an. Was folgt, ist eine Umleitung zu einem Authentifizierungs-Mechanismus unter Verwendung der folgenden in ApplicationController.before_filter
:
redirect_to controller: 'sessions', action: 'index'
Wie erwartet, werde ich http://domain.tld/sessions/ weitergeleitet. Jetzt möchte ich konfigurieren, dass Rails global auf http://domain.tld/foo/sessions/ umgeleitet wird, ohne es bei jeder Weiterleitung explizit zu erwähnen.
Ich habe versucht, diese mit in config/Umgebungen/production.rb:
config.relative_url_root = '/foo'
config.action_controller.relative_url_root = '/foo'
Und damit Einhorn Start:
RAILS_RELATIVE_URL_ROOT='/foo' bundle exec unicorn -c config/unicorn.rb -E production -p 8080
Leider ist dies nicht funktioniert. Es ändert das Verhalten überhaupt nicht. Ich habe Debug-Ausgabe vor der Weiterleitung hinzugefügt, um zu sehen, was los ist.
puts Rails.application.config.relative_url_root
puts ENV['RAILS_RELATIVE_URL_ROOT']
puts url_for controller: 'sessions', action: 'index'
Dies gibt:
/foo
/foo
http://domain.tld/sessions
jemand mir sagen kann, warum Rails die Konfiguration berücksichtigt nicht nehmen?