Ruby on Rails - Devise e Rails Admin doesn't work in production subdomain
I'm using Rails Admin with Devise in my application. That application is on a subdomain (app.site.com).
In development environment the login in Rails Admin works well, but in production when I try sign in (after click in login) i am redirected to my home page and login don't happened.
rails_admin.rb
RailsAdmin.config do |config|
config.main_app_name = ["App Name", "Backoffice"]
config.authenticate_with do
warden.authenticate! scope: :admin
end
config.current_user_method(&:current_admin)
end
routes.rb
require 'sidekiq/web'
Rails.application.routes.draw do
devise_for :admins, :controllers => :sessions => 'admin/sessions', :passwords => 'admin/passwords'
mount RailsAdmin::Engine => 'admin', as: 'rails_admin'
end
production.log
I, [2018-11-13T19:20:09.853115 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Started POST "/admins/sign_in" for 189.5.44.203 at 2018-11-13 19:20:09 -0200
I, [2018-11-13T19:20:09.854156 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Processing by Admin::SessionsController#create as HTML
I, [2018-11-13T19:20:09.854249 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Parameters: "utf8"=>"✓", "authenticity_token"=>"rBlkn39HWWPhIgKEDZtHIxeCgvw2vxu8KBGjbO+W2tjidD3c+a6g04G6tJXURDgoZw+CbDbMTZWugXGhaGewjA==", "admin"=>"email"=>"web@atua.ag", "password"=>"[FILTERED]", "remember_me"=>"0", "commit"=>"Login"
W, [2018-11-13T19:20:09.855012 #22050] WARN -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] HTTP Origin header (https://eventos.facens.br) didn't match request.base_url (http://eventos.facens.br)
D, [2018-11-13T19:20:09.856962 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Event Load (0.5ms) SELECT "events".* FROM "events" WHERE "events"."is_featured" = $1 AND (event_start > '2018-11-13') ORDER BY "events"."id" DESC LIMIT $2 [["is_featured", true], ["LIMIT", 1]]
D, [2018-11-13T19:20:09.857900 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] ConfigSite Load (0.3ms) SELECT "config_sites".* FROM "config_sites" ORDER BY "config_sites"."id" DESC LIMIT $1 [["LIMIT", 1]]
D, [2018-11-13T19:20:09.859423 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Admin Load (0.4ms) SELECT "admins".* FROM "admins" WHERE "admins"."email" = $1 ORDER BY "admins"."id" ASC LIMIT $2[["email", "web@atua.ag"], ["LIMIT", 1]]
D, [2018-11-13T19:20:09.971632 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] (0.3ms) BEGIN
D, [2018-11-13T19:20:09.974645 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Admin Update (0.6ms) UPDATE "admins" SET "current_sign_in_at" = $1, "last_sign_in_at" = $2, "last_sign_in_ip" = $3, "sign_in_count" = $4, "updated_at" = $5 WHERE "admins"."id" = $6 [["current_sign_in_at", "2018-11-13 21:20:09.970556"], ["last_sign_in_at", "2018-11-13 21:19:44.092713"], ["last_sign_in_ip", "189.5.44.203"], ["sign_in_count", 9], ["updated_at", "2018-11-13 21:20:09.972299"], ["id", 1]]
D, [2018-11-13T19:20:09.979743 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] (4.3ms) COMMIT
I, [2018-11-13T19:20:09.981750 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Redirected to http://eventos.facens.br/
I, [2018-11-13T19:20:09.982042 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Completed 302 Found in 128ms (ActiveRecord: 6.3ms)
I, [2018-11-13T19:20:10.337732 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Started GET "/" for 189.5.44.203 at 2018-11-13 19:20:10 -0200
I, [2018-11-13T19:20:10.338570 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Processing by HomeController#index as HTML
D, [2018-11-13T19:20:10.340691 #22050] DEBUG -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Event Load (0.5ms) SELECT "events".* FROM "events" WHERE "events"."is_featured" = $1 AND (event_start > '2018-11-13') ORDER BY "events"."id" DESC LIMIT $2 [["is_featured", true], ["LIMIT", 1]]
D, [2018-11-13T19:20:10.341635 #22050] DEBUG -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] ConfigSite Load (0.3ms) SELECT "config_sites".* FROM "config_sites" ORDER BY "config_sites"."id" DESC LIMIT $1 [["LIMIT", 1]]
I, [2018-11-13T19:20:10.343036 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendering home/index.html.erb within layouts/application
I, [2018-11-13T19:20:10.343457 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_hero.html.erb (0.1ms)
I, [2018-11-13T19:20:10.344713 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_filter_form.html.erb (0.9ms)
I, [2018-11-13T19:20:10.344846 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_search.html.erb (1.2ms)
D, [2018-11-13T19:20:10.347126 #22050] DEBUG -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Event Load (1.8ms) SELECT "events".* FROM "events" WHERE (event_start > '2018-11-13') ORDER BY event_start ASC LIMIT $1 [["LIMIT", 8]]
I, [2018-11-13T19:20:10.352858 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_upcoming.html.erb (7.8ms)
I, [2018-11-13T19:20:10.353993 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_newsletter.html.erb (0.9ms)
I, [2018-11-13T19:20:10.354217 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_app.html.erb (0.0ms)
D, [2018-11-13T19:20:10.359666 #22050] DEBUG -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Faq Load (4.9ms) SELECT "faqs".* FROM "faqs" ORDER BY question ASC LIMIT $1 [["LIMIT", 6]]
I, [2018-11-13T19:20:10.360394 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_faq.html.erb (6.0ms)
I, [2018-11-13T19:20:10.360524 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered home/index.html.erb within layouts/application (17.4ms)
I, [2018-11-13T19:20:10.363120 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered layouts/_header.html.erb (1.5ms)
I, [2018-11-13T19:20:10.364411 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_contact_form.html.erb (1.0ms)
I, [2018-11-13T19:20:10.364676 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered layouts/_footer.html.erb (1.3ms)
I, [2018-11-13T19:20:10.365098 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Completed 200 OK in 26ms (Views: 15.5ms | ActiveRecord: 7.4ms)
What can be going on? Does this have to do with the subdomain?
Thanks.
ruby-on-rails devise rails-admin
add a comment |
I'm using Rails Admin with Devise in my application. That application is on a subdomain (app.site.com).
In development environment the login in Rails Admin works well, but in production when I try sign in (after click in login) i am redirected to my home page and login don't happened.
rails_admin.rb
RailsAdmin.config do |config|
config.main_app_name = ["App Name", "Backoffice"]
config.authenticate_with do
warden.authenticate! scope: :admin
end
config.current_user_method(&:current_admin)
end
routes.rb
require 'sidekiq/web'
Rails.application.routes.draw do
devise_for :admins, :controllers => :sessions => 'admin/sessions', :passwords => 'admin/passwords'
mount RailsAdmin::Engine => 'admin', as: 'rails_admin'
end
production.log
I, [2018-11-13T19:20:09.853115 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Started POST "/admins/sign_in" for 189.5.44.203 at 2018-11-13 19:20:09 -0200
I, [2018-11-13T19:20:09.854156 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Processing by Admin::SessionsController#create as HTML
I, [2018-11-13T19:20:09.854249 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Parameters: "utf8"=>"✓", "authenticity_token"=>"rBlkn39HWWPhIgKEDZtHIxeCgvw2vxu8KBGjbO+W2tjidD3c+a6g04G6tJXURDgoZw+CbDbMTZWugXGhaGewjA==", "admin"=>"email"=>"web@atua.ag", "password"=>"[FILTERED]", "remember_me"=>"0", "commit"=>"Login"
W, [2018-11-13T19:20:09.855012 #22050] WARN -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] HTTP Origin header (https://eventos.facens.br) didn't match request.base_url (http://eventos.facens.br)
D, [2018-11-13T19:20:09.856962 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Event Load (0.5ms) SELECT "events".* FROM "events" WHERE "events"."is_featured" = $1 AND (event_start > '2018-11-13') ORDER BY "events"."id" DESC LIMIT $2 [["is_featured", true], ["LIMIT", 1]]
D, [2018-11-13T19:20:09.857900 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] ConfigSite Load (0.3ms) SELECT "config_sites".* FROM "config_sites" ORDER BY "config_sites"."id" DESC LIMIT $1 [["LIMIT", 1]]
D, [2018-11-13T19:20:09.859423 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Admin Load (0.4ms) SELECT "admins".* FROM "admins" WHERE "admins"."email" = $1 ORDER BY "admins"."id" ASC LIMIT $2[["email", "web@atua.ag"], ["LIMIT", 1]]
D, [2018-11-13T19:20:09.971632 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] (0.3ms) BEGIN
D, [2018-11-13T19:20:09.974645 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Admin Update (0.6ms) UPDATE "admins" SET "current_sign_in_at" = $1, "last_sign_in_at" = $2, "last_sign_in_ip" = $3, "sign_in_count" = $4, "updated_at" = $5 WHERE "admins"."id" = $6 [["current_sign_in_at", "2018-11-13 21:20:09.970556"], ["last_sign_in_at", "2018-11-13 21:19:44.092713"], ["last_sign_in_ip", "189.5.44.203"], ["sign_in_count", 9], ["updated_at", "2018-11-13 21:20:09.972299"], ["id", 1]]
D, [2018-11-13T19:20:09.979743 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] (4.3ms) COMMIT
I, [2018-11-13T19:20:09.981750 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Redirected to http://eventos.facens.br/
I, [2018-11-13T19:20:09.982042 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Completed 302 Found in 128ms (ActiveRecord: 6.3ms)
I, [2018-11-13T19:20:10.337732 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Started GET "/" for 189.5.44.203 at 2018-11-13 19:20:10 -0200
I, [2018-11-13T19:20:10.338570 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Processing by HomeController#index as HTML
D, [2018-11-13T19:20:10.340691 #22050] DEBUG -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Event Load (0.5ms) SELECT "events".* FROM "events" WHERE "events"."is_featured" = $1 AND (event_start > '2018-11-13') ORDER BY "events"."id" DESC LIMIT $2 [["is_featured", true], ["LIMIT", 1]]
D, [2018-11-13T19:20:10.341635 #22050] DEBUG -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] ConfigSite Load (0.3ms) SELECT "config_sites".* FROM "config_sites" ORDER BY "config_sites"."id" DESC LIMIT $1 [["LIMIT", 1]]
I, [2018-11-13T19:20:10.343036 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendering home/index.html.erb within layouts/application
I, [2018-11-13T19:20:10.343457 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_hero.html.erb (0.1ms)
I, [2018-11-13T19:20:10.344713 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_filter_form.html.erb (0.9ms)
I, [2018-11-13T19:20:10.344846 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_search.html.erb (1.2ms)
D, [2018-11-13T19:20:10.347126 #22050] DEBUG -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Event Load (1.8ms) SELECT "events".* FROM "events" WHERE (event_start > '2018-11-13') ORDER BY event_start ASC LIMIT $1 [["LIMIT", 8]]
I, [2018-11-13T19:20:10.352858 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_upcoming.html.erb (7.8ms)
I, [2018-11-13T19:20:10.353993 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_newsletter.html.erb (0.9ms)
I, [2018-11-13T19:20:10.354217 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_app.html.erb (0.0ms)
D, [2018-11-13T19:20:10.359666 #22050] DEBUG -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Faq Load (4.9ms) SELECT "faqs".* FROM "faqs" ORDER BY question ASC LIMIT $1 [["LIMIT", 6]]
I, [2018-11-13T19:20:10.360394 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_faq.html.erb (6.0ms)
I, [2018-11-13T19:20:10.360524 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered home/index.html.erb within layouts/application (17.4ms)
I, [2018-11-13T19:20:10.363120 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered layouts/_header.html.erb (1.5ms)
I, [2018-11-13T19:20:10.364411 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_contact_form.html.erb (1.0ms)
I, [2018-11-13T19:20:10.364676 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered layouts/_footer.html.erb (1.3ms)
I, [2018-11-13T19:20:10.365098 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Completed 200 OK in 26ms (Views: 15.5ms | ActiveRecord: 7.4ms)
What can be going on? Does this have to do with the subdomain?
Thanks.
ruby-on-rails devise rails-admin
Perhaps has to do with the 's' in http as the log says: HTTP Origin header (eventos.facens.br) didn't match request.base_url (eventos.facens.br)
– Guilherme Nunes
Nov 13 '18 at 23:21
1
@GuilhermeNunes Thanks. I had not realized that. I edited my nginx config and application.rb and now works well. I answered my own question.
– Felipe Marcon
Nov 14 '18 at 0:03
add a comment |
I'm using Rails Admin with Devise in my application. That application is on a subdomain (app.site.com).
In development environment the login in Rails Admin works well, but in production when I try sign in (after click in login) i am redirected to my home page and login don't happened.
rails_admin.rb
RailsAdmin.config do |config|
config.main_app_name = ["App Name", "Backoffice"]
config.authenticate_with do
warden.authenticate! scope: :admin
end
config.current_user_method(&:current_admin)
end
routes.rb
require 'sidekiq/web'
Rails.application.routes.draw do
devise_for :admins, :controllers => :sessions => 'admin/sessions', :passwords => 'admin/passwords'
mount RailsAdmin::Engine => 'admin', as: 'rails_admin'
end
production.log
I, [2018-11-13T19:20:09.853115 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Started POST "/admins/sign_in" for 189.5.44.203 at 2018-11-13 19:20:09 -0200
I, [2018-11-13T19:20:09.854156 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Processing by Admin::SessionsController#create as HTML
I, [2018-11-13T19:20:09.854249 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Parameters: "utf8"=>"✓", "authenticity_token"=>"rBlkn39HWWPhIgKEDZtHIxeCgvw2vxu8KBGjbO+W2tjidD3c+a6g04G6tJXURDgoZw+CbDbMTZWugXGhaGewjA==", "admin"=>"email"=>"web@atua.ag", "password"=>"[FILTERED]", "remember_me"=>"0", "commit"=>"Login"
W, [2018-11-13T19:20:09.855012 #22050] WARN -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] HTTP Origin header (https://eventos.facens.br) didn't match request.base_url (http://eventos.facens.br)
D, [2018-11-13T19:20:09.856962 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Event Load (0.5ms) SELECT "events".* FROM "events" WHERE "events"."is_featured" = $1 AND (event_start > '2018-11-13') ORDER BY "events"."id" DESC LIMIT $2 [["is_featured", true], ["LIMIT", 1]]
D, [2018-11-13T19:20:09.857900 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] ConfigSite Load (0.3ms) SELECT "config_sites".* FROM "config_sites" ORDER BY "config_sites"."id" DESC LIMIT $1 [["LIMIT", 1]]
D, [2018-11-13T19:20:09.859423 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Admin Load (0.4ms) SELECT "admins".* FROM "admins" WHERE "admins"."email" = $1 ORDER BY "admins"."id" ASC LIMIT $2[["email", "web@atua.ag"], ["LIMIT", 1]]
D, [2018-11-13T19:20:09.971632 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] (0.3ms) BEGIN
D, [2018-11-13T19:20:09.974645 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Admin Update (0.6ms) UPDATE "admins" SET "current_sign_in_at" = $1, "last_sign_in_at" = $2, "last_sign_in_ip" = $3, "sign_in_count" = $4, "updated_at" = $5 WHERE "admins"."id" = $6 [["current_sign_in_at", "2018-11-13 21:20:09.970556"], ["last_sign_in_at", "2018-11-13 21:19:44.092713"], ["last_sign_in_ip", "189.5.44.203"], ["sign_in_count", 9], ["updated_at", "2018-11-13 21:20:09.972299"], ["id", 1]]
D, [2018-11-13T19:20:09.979743 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] (4.3ms) COMMIT
I, [2018-11-13T19:20:09.981750 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Redirected to http://eventos.facens.br/
I, [2018-11-13T19:20:09.982042 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Completed 302 Found in 128ms (ActiveRecord: 6.3ms)
I, [2018-11-13T19:20:10.337732 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Started GET "/" for 189.5.44.203 at 2018-11-13 19:20:10 -0200
I, [2018-11-13T19:20:10.338570 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Processing by HomeController#index as HTML
D, [2018-11-13T19:20:10.340691 #22050] DEBUG -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Event Load (0.5ms) SELECT "events".* FROM "events" WHERE "events"."is_featured" = $1 AND (event_start > '2018-11-13') ORDER BY "events"."id" DESC LIMIT $2 [["is_featured", true], ["LIMIT", 1]]
D, [2018-11-13T19:20:10.341635 #22050] DEBUG -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] ConfigSite Load (0.3ms) SELECT "config_sites".* FROM "config_sites" ORDER BY "config_sites"."id" DESC LIMIT $1 [["LIMIT", 1]]
I, [2018-11-13T19:20:10.343036 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendering home/index.html.erb within layouts/application
I, [2018-11-13T19:20:10.343457 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_hero.html.erb (0.1ms)
I, [2018-11-13T19:20:10.344713 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_filter_form.html.erb (0.9ms)
I, [2018-11-13T19:20:10.344846 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_search.html.erb (1.2ms)
D, [2018-11-13T19:20:10.347126 #22050] DEBUG -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Event Load (1.8ms) SELECT "events".* FROM "events" WHERE (event_start > '2018-11-13') ORDER BY event_start ASC LIMIT $1 [["LIMIT", 8]]
I, [2018-11-13T19:20:10.352858 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_upcoming.html.erb (7.8ms)
I, [2018-11-13T19:20:10.353993 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_newsletter.html.erb (0.9ms)
I, [2018-11-13T19:20:10.354217 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_app.html.erb (0.0ms)
D, [2018-11-13T19:20:10.359666 #22050] DEBUG -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Faq Load (4.9ms) SELECT "faqs".* FROM "faqs" ORDER BY question ASC LIMIT $1 [["LIMIT", 6]]
I, [2018-11-13T19:20:10.360394 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_faq.html.erb (6.0ms)
I, [2018-11-13T19:20:10.360524 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered home/index.html.erb within layouts/application (17.4ms)
I, [2018-11-13T19:20:10.363120 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered layouts/_header.html.erb (1.5ms)
I, [2018-11-13T19:20:10.364411 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_contact_form.html.erb (1.0ms)
I, [2018-11-13T19:20:10.364676 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered layouts/_footer.html.erb (1.3ms)
I, [2018-11-13T19:20:10.365098 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Completed 200 OK in 26ms (Views: 15.5ms | ActiveRecord: 7.4ms)
What can be going on? Does this have to do with the subdomain?
Thanks.
ruby-on-rails devise rails-admin
I'm using Rails Admin with Devise in my application. That application is on a subdomain (app.site.com).
In development environment the login in Rails Admin works well, but in production when I try sign in (after click in login) i am redirected to my home page and login don't happened.
rails_admin.rb
RailsAdmin.config do |config|
config.main_app_name = ["App Name", "Backoffice"]
config.authenticate_with do
warden.authenticate! scope: :admin
end
config.current_user_method(&:current_admin)
end
routes.rb
require 'sidekiq/web'
Rails.application.routes.draw do
devise_for :admins, :controllers => :sessions => 'admin/sessions', :passwords => 'admin/passwords'
mount RailsAdmin::Engine => 'admin', as: 'rails_admin'
end
production.log
I, [2018-11-13T19:20:09.853115 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Started POST "/admins/sign_in" for 189.5.44.203 at 2018-11-13 19:20:09 -0200
I, [2018-11-13T19:20:09.854156 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Processing by Admin::SessionsController#create as HTML
I, [2018-11-13T19:20:09.854249 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Parameters: "utf8"=>"✓", "authenticity_token"=>"rBlkn39HWWPhIgKEDZtHIxeCgvw2vxu8KBGjbO+W2tjidD3c+a6g04G6tJXURDgoZw+CbDbMTZWugXGhaGewjA==", "admin"=>"email"=>"web@atua.ag", "password"=>"[FILTERED]", "remember_me"=>"0", "commit"=>"Login"
W, [2018-11-13T19:20:09.855012 #22050] WARN -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] HTTP Origin header (https://eventos.facens.br) didn't match request.base_url (http://eventos.facens.br)
D, [2018-11-13T19:20:09.856962 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Event Load (0.5ms) SELECT "events".* FROM "events" WHERE "events"."is_featured" = $1 AND (event_start > '2018-11-13') ORDER BY "events"."id" DESC LIMIT $2 [["is_featured", true], ["LIMIT", 1]]
D, [2018-11-13T19:20:09.857900 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] ConfigSite Load (0.3ms) SELECT "config_sites".* FROM "config_sites" ORDER BY "config_sites"."id" DESC LIMIT $1 [["LIMIT", 1]]
D, [2018-11-13T19:20:09.859423 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Admin Load (0.4ms) SELECT "admins".* FROM "admins" WHERE "admins"."email" = $1 ORDER BY "admins"."id" ASC LIMIT $2[["email", "web@atua.ag"], ["LIMIT", 1]]
D, [2018-11-13T19:20:09.971632 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] (0.3ms) BEGIN
D, [2018-11-13T19:20:09.974645 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Admin Update (0.6ms) UPDATE "admins" SET "current_sign_in_at" = $1, "last_sign_in_at" = $2, "last_sign_in_ip" = $3, "sign_in_count" = $4, "updated_at" = $5 WHERE "admins"."id" = $6 [["current_sign_in_at", "2018-11-13 21:20:09.970556"], ["last_sign_in_at", "2018-11-13 21:19:44.092713"], ["last_sign_in_ip", "189.5.44.203"], ["sign_in_count", 9], ["updated_at", "2018-11-13 21:20:09.972299"], ["id", 1]]
D, [2018-11-13T19:20:09.979743 #22050] DEBUG -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] (4.3ms) COMMIT
I, [2018-11-13T19:20:09.981750 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Redirected to http://eventos.facens.br/
I, [2018-11-13T19:20:09.982042 #22050] INFO -- : [d3f1ce41-3c11-4a53-896f-a5ef4cdea7d0] Completed 302 Found in 128ms (ActiveRecord: 6.3ms)
I, [2018-11-13T19:20:10.337732 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Started GET "/" for 189.5.44.203 at 2018-11-13 19:20:10 -0200
I, [2018-11-13T19:20:10.338570 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Processing by HomeController#index as HTML
D, [2018-11-13T19:20:10.340691 #22050] DEBUG -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Event Load (0.5ms) SELECT "events".* FROM "events" WHERE "events"."is_featured" = $1 AND (event_start > '2018-11-13') ORDER BY "events"."id" DESC LIMIT $2 [["is_featured", true], ["LIMIT", 1]]
D, [2018-11-13T19:20:10.341635 #22050] DEBUG -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] ConfigSite Load (0.3ms) SELECT "config_sites".* FROM "config_sites" ORDER BY "config_sites"."id" DESC LIMIT $1 [["LIMIT", 1]]
I, [2018-11-13T19:20:10.343036 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendering home/index.html.erb within layouts/application
I, [2018-11-13T19:20:10.343457 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_hero.html.erb (0.1ms)
I, [2018-11-13T19:20:10.344713 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_filter_form.html.erb (0.9ms)
I, [2018-11-13T19:20:10.344846 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_search.html.erb (1.2ms)
D, [2018-11-13T19:20:10.347126 #22050] DEBUG -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Event Load (1.8ms) SELECT "events".* FROM "events" WHERE (event_start > '2018-11-13') ORDER BY event_start ASC LIMIT $1 [["LIMIT", 8]]
I, [2018-11-13T19:20:10.352858 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_upcoming.html.erb (7.8ms)
I, [2018-11-13T19:20:10.353993 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_newsletter.html.erb (0.9ms)
I, [2018-11-13T19:20:10.354217 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_app.html.erb (0.0ms)
D, [2018-11-13T19:20:10.359666 #22050] DEBUG -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Faq Load (4.9ms) SELECT "faqs".* FROM "faqs" ORDER BY question ASC LIMIT $1 [["LIMIT", 6]]
I, [2018-11-13T19:20:10.360394 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_faq.html.erb (6.0ms)
I, [2018-11-13T19:20:10.360524 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered home/index.html.erb within layouts/application (17.4ms)
I, [2018-11-13T19:20:10.363120 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered layouts/_header.html.erb (1.5ms)
I, [2018-11-13T19:20:10.364411 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered shared/_contact_form.html.erb (1.0ms)
I, [2018-11-13T19:20:10.364676 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Rendered layouts/_footer.html.erb (1.3ms)
I, [2018-11-13T19:20:10.365098 #22050] INFO -- : [6d62d29b-c18f-4197-96e7-19ff116f7a3e] Completed 200 OK in 26ms (Views: 15.5ms | ActiveRecord: 7.4ms)
What can be going on? Does this have to do with the subdomain?
Thanks.
ruby-on-rails devise rails-admin
ruby-on-rails devise rails-admin
edited Nov 13 '18 at 22:16
Felipe Marcon
asked Nov 13 '18 at 22:02
Felipe MarconFelipe Marcon
9410
9410
Perhaps has to do with the 's' in http as the log says: HTTP Origin header (eventos.facens.br) didn't match request.base_url (eventos.facens.br)
– Guilherme Nunes
Nov 13 '18 at 23:21
1
@GuilhermeNunes Thanks. I had not realized that. I edited my nginx config and application.rb and now works well. I answered my own question.
– Felipe Marcon
Nov 14 '18 at 0:03
add a comment |
Perhaps has to do with the 's' in http as the log says: HTTP Origin header (eventos.facens.br) didn't match request.base_url (eventos.facens.br)
– Guilherme Nunes
Nov 13 '18 at 23:21
1
@GuilhermeNunes Thanks. I had not realized that. I edited my nginx config and application.rb and now works well. I answered my own question.
– Felipe Marcon
Nov 14 '18 at 0:03
Perhaps has to do with the 's' in http as the log says: HTTP Origin header (eventos.facens.br) didn't match request.base_url (eventos.facens.br)
– Guilherme Nunes
Nov 13 '18 at 23:21
Perhaps has to do with the 's' in http as the log says: HTTP Origin header (eventos.facens.br) didn't match request.base_url (eventos.facens.br)
– Guilherme Nunes
Nov 13 '18 at 23:21
1
1
@GuilhermeNunes Thanks. I had not realized that. I edited my nginx config and application.rb and now works well. I answered my own question.
– Felipe Marcon
Nov 14 '18 at 0:03
@GuilhermeNunes Thanks. I had not realized that. I edited my nginx config and application.rb and now works well. I answered my own question.
– Felipe Marcon
Nov 14 '18 at 0:03
add a comment |
2 Answers
2
active
oldest
votes
Devise must be redirecting you to your root_path
which might have been set on config/routes.rb
.
You can have a look at devise's documentation to get what you want.
https://github.com/plataformatec/devise/wiki/How-To:-redirect-to-a-specific-page-on-successful-sign-in
The code bellow its shown on the tutorial above. So following the code bellow you might have to overwrite the after_sign_in_path_for
devise's method to redirect to the subdomain.
class ApplicationController < ActionController::Base
protected
def after_sign_in_path_for(resource)
request.env['omniauth.origin'] || stored_location_for(resource) || root_path
end
end
Hope that helped you in some way.
Cheers
add a comment |
That was just a problem with my Nginx config because SSL.
I added these lines to Nginx:
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Ssl on; # Optional
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Host $host;
And that to my application.rbconfig.action_controller.forgery_protection_origin_check = false
Now it works well.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290175%2fruby-on-rails-devise-e-rails-admin-doesnt-work-in-production-subdomain%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Devise must be redirecting you to your root_path
which might have been set on config/routes.rb
.
You can have a look at devise's documentation to get what you want.
https://github.com/plataformatec/devise/wiki/How-To:-redirect-to-a-specific-page-on-successful-sign-in
The code bellow its shown on the tutorial above. So following the code bellow you might have to overwrite the after_sign_in_path_for
devise's method to redirect to the subdomain.
class ApplicationController < ActionController::Base
protected
def after_sign_in_path_for(resource)
request.env['omniauth.origin'] || stored_location_for(resource) || root_path
end
end
Hope that helped you in some way.
Cheers
add a comment |
Devise must be redirecting you to your root_path
which might have been set on config/routes.rb
.
You can have a look at devise's documentation to get what you want.
https://github.com/plataformatec/devise/wiki/How-To:-redirect-to-a-specific-page-on-successful-sign-in
The code bellow its shown on the tutorial above. So following the code bellow you might have to overwrite the after_sign_in_path_for
devise's method to redirect to the subdomain.
class ApplicationController < ActionController::Base
protected
def after_sign_in_path_for(resource)
request.env['omniauth.origin'] || stored_location_for(resource) || root_path
end
end
Hope that helped you in some way.
Cheers
add a comment |
Devise must be redirecting you to your root_path
which might have been set on config/routes.rb
.
You can have a look at devise's documentation to get what you want.
https://github.com/plataformatec/devise/wiki/How-To:-redirect-to-a-specific-page-on-successful-sign-in
The code bellow its shown on the tutorial above. So following the code bellow you might have to overwrite the after_sign_in_path_for
devise's method to redirect to the subdomain.
class ApplicationController < ActionController::Base
protected
def after_sign_in_path_for(resource)
request.env['omniauth.origin'] || stored_location_for(resource) || root_path
end
end
Hope that helped you in some way.
Cheers
Devise must be redirecting you to your root_path
which might have been set on config/routes.rb
.
You can have a look at devise's documentation to get what you want.
https://github.com/plataformatec/devise/wiki/How-To:-redirect-to-a-specific-page-on-successful-sign-in
The code bellow its shown on the tutorial above. So following the code bellow you might have to overwrite the after_sign_in_path_for
devise's method to redirect to the subdomain.
class ApplicationController < ActionController::Base
protected
def after_sign_in_path_for(resource)
request.env['omniauth.origin'] || stored_location_for(resource) || root_path
end
end
Hope that helped you in some way.
Cheers
edited Nov 13 '18 at 23:40
answered Nov 13 '18 at 23:21
adrianorobadrianorob
187
187
add a comment |
add a comment |
That was just a problem with my Nginx config because SSL.
I added these lines to Nginx:
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Ssl on; # Optional
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Host $host;
And that to my application.rbconfig.action_controller.forgery_protection_origin_check = false
Now it works well.
add a comment |
That was just a problem with my Nginx config because SSL.
I added these lines to Nginx:
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Ssl on; # Optional
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Host $host;
And that to my application.rbconfig.action_controller.forgery_protection_origin_check = false
Now it works well.
add a comment |
That was just a problem with my Nginx config because SSL.
I added these lines to Nginx:
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Ssl on; # Optional
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Host $host;
And that to my application.rbconfig.action_controller.forgery_protection_origin_check = false
Now it works well.
That was just a problem with my Nginx config because SSL.
I added these lines to Nginx:
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Ssl on; # Optional
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Host $host;
And that to my application.rbconfig.action_controller.forgery_protection_origin_check = false
Now it works well.
answered Nov 14 '18 at 0:07
Felipe MarconFelipe Marcon
9410
9410
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290175%2fruby-on-rails-devise-e-rails-admin-doesnt-work-in-production-subdomain%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Perhaps has to do with the 's' in http as the log says: HTTP Origin header (eventos.facens.br) didn't match request.base_url (eventos.facens.br)
– Guilherme Nunes
Nov 13 '18 at 23:21
1
@GuilhermeNunes Thanks. I had not realized that. I edited my nginx config and application.rb and now works well. I answered my own question.
– Felipe Marcon
Nov 14 '18 at 0:03