I am trying to configure a Rails 3 application behind an Apache2 web server, which acts as a proxy. The Apache web server runs on port 8080, and if I make a call to http: // ip: 8080 , I see the request in the mongrel window, so the proxy server correctly sends incoming requests to the mongrel servers.
However, my index page redirects to login if the username does not exist. So I make the following call: http: //: 8080 / app, but the redirection goes to http: /// session / new instead of http: /// app / sessio / new I'm not sure that apache is configured poorly, I doubt it more in rails 3.
Below is the configuration of my apache for this proxy file, my route.rb file and some code that I found for a potential proxy fix, but it does not seem to work.
REVERSE_PROXY_FIX
BASE_URL = ''
module ActionController
ActionController::Base.asset_host= BASE_URL
class UrlRewriter
def rewrite_url(path, options)
url = old_rewrite_url(path, options)
url = url.gsub(@request.protocol + @request.host_with_port, '')
url = BASE_URL + url
url
end
end
end
Apache2 config
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
Alias /Esco "c:/web/esco/public"
<Directory "C:/web/esco/public">
Options Indexes FollowSymLinks
AllowOverride none
Order allow,deny
Allow from all
</Directory>
ProxyPass /Esco/images !
ProxyPass /Esco/stylesheets !
ProxyPass /Esco/javascripts !
ProxyPass /Esco/ http://127.0.0.1:4000/
ProxyPass /Esco http://127.0.0.1:4000/
ProxyPassReverse /Esco/ http://127.0.0.1:4000/
routes.rb
ESCO::Application.routes.draw do
root :to => 'static#index'
resources :cvs
match 'cvs/match' => 'cvs#match', :as => :match_resume, :via => :post
match 'session/new' => 'session#new', :as => :new_session, :via => :get
match 'session/create' => 'session#create', :as => :create_session, :via => :put
match 'session/destroy' => 'session#destroy', :as => :destroy_session, :via => :delete
match 'admin' => 'admin/static#index', :as => :admin_index, :via => :get
match 'admin/cvs/save' => 'admin/cvs#save', :as => :admin_save_cv, :via => :post
namespace "admin" do
resources :users, :cvs, :settings, :languages, :vacancies, :countries, :languages
end
end
I also like mnetion that apache works on a Windows Server 2008R2 x64 system and that rails applications run inside a Mongrel server on the same system starting from port 4000 β 4010. I hope someone can help me sort this reverse proxy server .
EDIT : I updated the config.ru file to run the application from the same subfolder domain as the proxy, and this allows me to view views, etc., but at the same time there are not enough stylesheets and images.
Mongrel gets the following:
Started GET "/Esco/" for 81.82.197.2 at 2011-05-09 13:25:44 +0200
Processing by StaticController#index as HTML
Rendered static/index.html.haml within layouts/application (15.6ms)
Completed 200 OK in 31ms (Views: 31.2ms | ActiveRecord: 0.0ms)
And if I go directly to the styles, I will see them.