I am facing an issue that drives me crazy – mostly because there are no logs or error messages and the fact that it works on localhost but not production.
The issue:
I go to login page – enter the credentials (100% correct) and hit the login button. Not logged on and no message, no log entries, not logged on. It works as expected on localhost.
There is little I can give you despite the configuration I am working with- and I am hoping someone else faced this issue and was able to resolve it.
Ubuntu version:
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty
Rails version:
Rails 5.0.1
Ruby version:
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
Devise version:
devise (4.2.0)
Nginx version:
nginx version: nginx/1.10.2
Passenger version:
Phusion Passenger 5.1.2
Production Log:
I, [2017-02-19T16:42:34.671850 #12709] INFO -- : [2c7d1cea-31d4-414f-a3bf-0ca1f0434a66] Processing by StaticPagesController#teaser as HTML
I, [2017-02-19T16:42:34.672014 #12709] INFO -- : [2c7d1cea-31d4-414f-a3bf-0ca1f0434a66] Parameters: {"locale"=>"en"}
I, [2017-02-19T16:42:34.678782 #12709] INFO -- : [2c7d1cea-31d4-414f-a3bf-0ca1f0434a66] Rendering static_pages/teaser.html.haml within layouts/teaser
I, [2017-02-19T16:42:34.719835 #12709] INFO -- : [2c7d1cea-31d4-414f-a3bf-0ca1f0434a66] Rendered static_pages/teaser.html.haml within layouts/teaser (40.8ms)
I, [2017-02-19T16:42:34.729883 #12709] INFO -- : [2c7d1cea-31d4-414f-a3bf-0ca1f0434a66] Rendered layouts/tracking/_google_analytics.html.haml (1.7ms)
I, [2017-02-19T16:42:34.737139 #12709] INFO -- : [2c7d1cea-31d4-414f-a3bf-0ca1f0434a66] Rendered layouts/navs/_navigation_teaser.html.haml (6.4ms)
I, [2017-02-19T16:42:34.740481 #12709] INFO -- : [2c7d1cea-31d4-414f-a3bf-0ca1f0434a66] Rendered layouts/footers/_bottom.html.haml (2.4ms)
I, [2017-02-19T16:42:34.741421 #12709] INFO -- : [2c7d1cea-31d4-414f-a3bf-0ca1f0434a66] Completed 200 OK in 69ms (Views: 66.8ms)
D, [2017-02-19T16:42:34.743712 #12709] DEBUG -- : [2c7d1cea-31d4-414f-a3bf-0ca1f0434a66] DEBUG: Chewy strategies stack: [2] -> atomic @ /usr/local/lib/ruby/gems/2.4.0/gems/chewy-0.9.0/lib/chewy/railtie.rb:17
I, [2017-02-19T16:42:38.140233 #12709] INFO -- : [efa8a6ab-c0a9-40c5-ad5c-efc5fea35ff2] Started GET "/en/users/login/" for 213.225.34.85 at 2017-02-19 16:42:38 +0100
D, [2017-02-19T16:42:38.140679 #12709] DEBUG -- : [efa8a6ab-c0a9-40c5-ad5c-efc5fea35ff2] DEBUG: Chewy strategies stack: [2] <- atomic @ /usr/local/lib/ruby/gems/2.4.0/gems/chewy-0.9.0/lib/chewy/railtie.rb:17
I, [2017-02-19T16:42:38.143560 #12709] INFO -- : [efa8a6ab-c0a9-40c5-ad5c-efc5fea35ff2] Processing by Devise::SessionsController#new as HTML
I, [2017-02-19T16:42:38.143632 #12709] INFO -- : [efa8a6ab-c0a9-40c5-ad5c-efc5fea35ff2] Parameters: {"locale"=>"en"}
I, [2017-02-19T16:42:38.181675 #12709] INFO -- : [efa8a6ab-c0a9-40c5-ad5c-efc5fea35ff2] Rendering devise/sessions/new.html.haml within layouts/devise
I, [2017-02-19T16:42:38.189833 #12709] INFO -- : [efa8a6ab-c0a9-40c5-ad5c-efc5fea35ff2] Rendered devise/sessions/new.html.haml within layouts/devise (8.0ms)
I, [2017-02-19T16:42:38.196498 #12709] INFO -- : [efa8a6ab-c0a9-40c5-ad5c-efc5fea35ff2] Rendered layouts/tracking/_google_analytics.html.haml (0.3ms)
I, [2017-02-19T16:42:38.199537 #12709] INFO -- : [efa8a6ab-c0a9-40c5-ad5c-efc5fea35ff2] Rendered layouts/_error_messages.html.haml (2.2ms)
I, [2017-02-19T16:42:38.201012 #12709] INFO -- : [efa8a6ab-c0a9-40c5-ad5c-efc5fea35ff2] Rendered layouts/footers/_bottom_devise.html.haml (0.8ms)
I, [2017-02-19T16:42:38.201777 #12709] INFO -- : [efa8a6ab-c0a9-40c5-ad5c-efc5fea35ff2] Completed 200 OK in 58ms (Views: 23.5ms | ActiveRecord: 2.2ms)
D, [2017-02-19T16:42:38.202966 #12709] DEBUG -- : [efa8a6ab-c0a9-40c5-ad5c-efc5fea35ff2] DEBUG: Chewy strategies stack: [2] -> atomic @ /usr/local/lib/ruby/gems/2.4.0/gems/chewy-0.9.0/lib/chewy/railtie.rb:17
I, [2017-02-19T16:42:42.616812 #12709] INFO -- : [3d15563f-bb6c-4a4e-84b4-46e473e237be] Started GET "/en/users/login/" for 213.225.34.85 at 2017-02-19 16:42:42 +0100
D, [2017-02-19T16:42:42.617237 #12709] DEBUG -- : [3d15563f-bb6c-4a4e-84b4-46e473e237be] DEBUG: Chewy strategies stack: [2] <- atomic @ /usr/local/lib/ruby/gems/2.4.0/gems/chewy-0.9.0/lib/chewy/railtie.rb:17
I, [2017-02-19T16:42:42.618504 #12709] INFO -- : [3d15563f-bb6c-4a4e-84b4-46e473e237be] Processing by Devise::SessionsController#new as HTML
I, [2017-02-19T16:42:42.618574 #12709] INFO -- : [3d15563f-bb6c-4a4e-84b4-46e473e237be] Parameters: {"locale"=>"en"}
I, [2017-02-19T16:42:42.620779 #12709] INFO -- : [3d15563f-bb6c-4a4e-84b4-46e473e237be] Rendering devise/sessions/new.html.haml within layouts/devise
I, [2017-02-19T16:42:42.622348 #12709] INFO -- : [3d15563f-bb6c-4a4e-84b4-46e473e237be] Rendered devise/sessions/new.html.haml within layouts/devise (1.5ms)
I, [2017-02-19T16:42:42.624039 #12709] INFO -- : [3d15563f-bb6c-4a4e-84b4-46e473e237be] Rendered layouts/tracking/_google_analytics.html.haml (0.3ms)
I, [2017-02-19T16:42:42.624547 #12709] INFO -- : [3d15563f-bb6c-4a4e-84b4-46e473e237be] Rendered layouts/_error_messages.html.haml (0.2ms)
I, [2017-02-19T16:42:42.624961 #12709] INFO -- : [3d15563f-bb6c-4a4e-84b4-46e473e237be] Rendered layouts/footers/_bottom_devise.html.haml (0.2ms)
I, [2017-02-19T16:42:42.625530 #12709] INFO -- : [3d15563f-bb6c-4a4e-84b4-46e473e237be] Completed 200 OK in 7ms (Views: 5.0ms | ActiveRecord: 0.0ms)
D, [2017-02-19T16:42:42.626717 #12709] DEBUG -- : [3d15563f-bb6c-4a4e-84b4-46e473e237be] DEBUG: Chewy strategies stack: [2] -> atomic @ /usr/local/lib/ruby/gems/2.4.0/gems/chewy-0.9.0/lib/chewy/railtie.rb:17
Nginx Log (error.log):
[ 2017-02-19 16:39:22.3744 11673/7fbd8cdd47c0 age/Ust/UstRouterMain.cpp:492 ]: Received command to shutdown gracefully. Waiting until all clients have disconnected...
[ 2017-02-19 16:39:22.3744 11673/7fbd85dca700 Ser/Server.h:817 ]: [UstRouterApiServer] Freed 0 spare client objects
[ 2017-02-19 16:39:22.3745 11673/7fbd85dca700 Ser/Server.h:464 ]: [UstRouterApiServer] Shutdown finished
[ 2017-02-19 16:39:22.3747 11673/7fbd865cb700 Ser/Server.h:464 ]: [UstRouter] Shutdown finished
[ 2017-02-19 16:39:22.3748 11673/7fbd8cdd47c0 age/Ust/UstRouterMain.cpp:523 ]: Passenger UstRouter shutdown finished
[ 2017-02-19 16:39:22.6189 11663/7f5c6c8fe7c0 age/Cor/CoreMain.cpp:1055 ]: Passenger core shutdown finished
[ 2017-02-19 16:39:23.4450 12221/7fbf2251a7c0 age/Wat/WatchdogMain.cpp:1281 ]: Starting Passenger watchdog...
[ 2017-02-19 16:39:23.4539 12224/7f409d5e37c0 age/Cor/CoreMain.cpp:1070 ]: Starting Passenger core...
[ 2017-02-19 16:39:23.4541 12224/7f409d5e37c0 age/Cor/CoreMain.cpp:245 ]: Passenger core running in multi-application mode.
[ 2017-02-19 16:39:23.4585 12224/7f409d5e37c0 age/Cor/CoreMain.cpp:820 ]: Passenger core online, PID 12224
[ 2017-02-19 16:39:23.4675 12230/7f8a2efc77c0 age/Ust/UstRouterMain.cpp:529 ]: Starting Passenger UstRouter...
[ 2017-02-19 16:39:23.4685 12230/7f8a2efc77c0 age/Ust/UstRouterMain.cpp:342 ]: Passenger UstRouter online, PID 12230
[ 2017-02-19 16:39:25.6619 12224/7f409d4cb700 age/Cor/SecurityUpdateChecker.h:464 ]: Security update check: no update found (next check in 24 hours)
App 12257 stdout:
App 12382 stdout:
2017/02/19 16:42:21 [info] 12537#12537: Using 32768KiB of shared memory for nchan in /etc/nginx/nginx.conf:74
[ 2017-02-19 16:42:21.7235 12224/7f4096e14700 age/Cor/CoreMain.cpp:585 ]: Signal received. Gracefully shutting down... (send signal 2 more time(s) to force shutdown)
[ 2017-02-19 16:42:21.7236 12224/7f409d5e37c0 age/Cor/CoreMain.cpp:989 ]: Received command to shutdown gracefully. Waiting until all clients have disconnected...
[ 2017-02-19 16:42:21.7236 12224/7f409d5e37c0 age/Cor/CoreMain.cpp:907 ]: Checking whether to disconnect long-running connections for process 12382, application /home/sandbox/rails/windhagermediahub/public (production)
[ 2017-02-19 16:42:21.7239 12224/7f4096592700 Ser/Server.h:817 ]: [ServerThr.2] Freed 128 spare client objects
[ 2017-02-19 16:42:21.7239 12224/7f4096592700 Ser/Server.h:464 ]: [ServerThr.2] Shutdown finished
[ 2017-02-19 16:42:21.7242 12224/7f4096e14700 Ser/Server.h:817 ]: [ServerThr.1] Freed 128 spare client objects
[ 2017-02-19 16:42:21.7242 12224/7f4096e14700 Ser/Server.h:464 ]: [ServerThr.1] Shutdown finished
[ 2017-02-19 16:42:21.7243 12224/7f4095d10700 Ser/Server.h:817 ]: [ApiServer] Freed 0 spare client objects
[ 2017-02-19 16:42:21.7243 12224/7f4095d10700 Ser/Server.h:464 ]: [ApiServer] Shutdown finished
[ 2017-02-19 16:42:21.7244 12224/7f409d5e37c0 age/Cor/CoreMain.cpp:907 ]: Checking whether to disconnect long-running connections for process 12382, application /home/sandbox/rails/windhagermediahub/public (production)
[ 2017-02-19 16:42:21.7265 12230/7f8a23fff700 age/Ust/UstRouterMain.cpp:422 ]: Signal received. Gracefully shutting down... (send signal 2 more time(s) to force shutdown)
[ 2017-02-19 16:42:21.7266 12230/7f8a2efc77c0 age/Ust/UstRouterMain.cpp:492 ]: Received command to shutdown gracefully. Waiting until all clients have disconnected...
[ 2017-02-19 16:42:21.7266 12230/7f8a237fe700 Ser/Server.h:817 ]: [UstRouterApiServer] Freed 0 spare client objects
[ 2017-02-19 16:42:21.7266 12230/7f8a237fe700 Ser/Server.h:464 ]: [UstRouterApiServer] Shutdown finished
[ 2017-02-19 16:42:21.7268 12230/7f8a23fff700 Ser/Server.h:464 ]: [UstRouter] Shutdown finished
[ 2017-02-19 16:42:21.7272 12230/7f8a2efc77c0 age/Ust/UstRouterMain.cpp:523 ]: Passenger UstRouter shutdown finished
[ 2017-02-19 16:42:21.9690 12224/7f409d5e37c0 age/Cor/CoreMain.cpp:1055 ]: Passenger core shutdown finished
[ 2017-02-19 16:42:22.7904 12548/7f4dcba4d7c0 age/Wat/WatchdogMain.cpp:1281 ]: Starting Passenger watchdog...
[ 2017-02-19 16:42:22.8003 12551/7f388a8967c0 age/Cor/CoreMain.cpp:1070 ]: Starting Passenger core...
[ 2017-02-19 16:42:22.8005 12551/7f388a8967c0 age/Cor/CoreMain.cpp:245 ]: Passenger core running in multi-application mode.
[ 2017-02-19 16:42:22.8053 12551/7f388a8967c0 age/Cor/CoreMain.cpp:820 ]: Passenger core online, PID 12551
[ 2017-02-19 16:42:22.8155 12557/7fd30e4537c0 age/Ust/UstRouterMain.cpp:529 ]: Starting Passenger UstRouter...
[ 2017-02-19 16:42:22.8165 12557/7fd30e4537c0 age/Ust/UstRouterMain.cpp:342 ]: Passenger UstRouter online, PID 12557
[ 2017-02-19 16:42:24.9877 12551/7f388a77e700 age/Cor/SecurityUpdateChecker.h:464 ]: Security update check: no update found (next check in 24 hours)
App 12582 stdout:
App 12709 stdout:
UPDATE:
After replacing devise with Clearance, the issue persists. According to logs it is trying to issue a GET request, whilst it is supposed to be POST. The form works on localhost and everything looks correct. I even specified the method in the login form but it is still issuing a GET. I am biting dust here.
UPDATE2:
I removed Devise altogether and any references to it in the code and subsequently set it up again – No modifications or customisations are made to Devise. Standard views and Forms are being used.
SignIn Form (Session New)
<h2>Log in</h2>
<%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="form-inputs">
<%= f.input :email, required: false, autofocus: true %>
<%= f.input :password, required: false %>
<%= f.input :remember_me, as: :boolean if devise_mapping.rememberable? %>
</div>
<div class="form-actions">
<%= f.button :submit, "Log in" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
UPDATE 3
routes.rb
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root to: 'static_pages#redirect'
localized do
match '', to: 'static_pages#teaser', :as => 'teaser', via: 'get'
scope 'legal' do
match 'data-privacy', to: 'static_pages#data_privacy', :as => 'data-privacy', via: 'get'
match 'terms-of-use', to: 'static_pages#terms_of_use', :as => 'terms_of_use', via: 'get'
match 'cookie-policy', to: 'static_pages#cookie_policy', :as => 'cookie_policy', via: 'get'
end
devise_for :users, :path_names => {:sign_in => 'login', :sign_out => 'logout'}
scope 'dashboard' do
match 'wh-a-seo-at', to: 'dashboards#seo_at', :as => 'dashboard_seo_at', via: 'get'
match 'wh-a-seo-de', to: 'dashboards#seo_de', :as => 'dashboard_seo_de', via: 'get'
match 'wh-a-uiux', to: 'dashboards#uiux', :as => 'dashboard_uiux', via: 'get'
resources :links
resources :key_performance_indicators
resources :keyword_lists do
resources :keyword_dates
resources :keyword_groups do
resources :keywords do
resources :keyword_rankings
end
end
end
end
end
end
Output: RAILS_ENV=production bundle exec rake
georg$ RAILS_ENV=production bundle exec rake routes
Prefix Verb URI Pattern Controller#Action
root GET / static_pages#redirect
teaser_en GET /en static_pages#teaser {:locale=>"en"}
data_privacy_en GET /en/legal/data-privacy(.:format) static_pages#data_privacy {:locale=>"en"}
terms_of_use_en GET /en/legal/terms-of-use(.:format) static_pages#terms_of_use {:locale=>"en"}
cookie_policy_en GET /en/legal/cookie-policy(.:format) static_pages#cookie_policy {:locale=>"en"}
new_user_session_en GET /en/users/login(.:format) devise/sessions#new {:locale=>"en"}
user_session_en POST /en/users/login(.:format) devise/sessions#create {:locale=>"en"}
destroy_user_session_en DELETE /en/users/logout(.:format) devise/sessions#destroy {:locale=>"en"}
etc.
production.rb
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http://example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "PRODEV0007_#{Rails.env}"
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
config.active_record.dump_schema_after_migration = false
config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif *.svg application_split2.css )
# Tested force_ssl with true and false
config.force_ssl = true
config.i18n.fallbacks = true
end
Formatted Version of Form
<form novalidate="novalidate" class="simple_form new_user" id="new_user" action="/en/users/login" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="✓"><input type="hidden" name="authenticity_token" value="R5dzqGlWWGhP5UD6QvR9TEZatNgot8UYtfOwQbQO+Ksv7DEgoVNDL/LSk7cRcZsxUSHnn8T/XQLkDr9B+y0weQ==">
<div class="form-inputs">
<div class="input email optional user_email"><label class="email optional" for="user_email">Email</label><input class="string email optional" autofocus="autofocus" type="email" value="" name="user[email]" id="user_email"></div>
<div class="input password optional user_password"><label class="password optional" for="user_password">Password</label><input class="password optional" type="password" name="user[password]" id="user_password"></div>
<div class="input boolean optional user_remember_me"><input value="0" type="hidden" name="user[remember_me]"><label class="boolean optional checkbox" for="user_remember_me"><input class="boolean optional" type="checkbox" value="1" name="user[remember_me]" id="user_remember_me">Remember me</label></div>
</div>
<div class="form-actions">
<input type="submit" name="commit" value="Log in" class="btn" data-disable-with="Log in">
</div>
</form>
user.rb
class User < ApplicationRecord
#include Clearance::User
extend FriendlyId
friendly_id :slug_candidates, use: :slugged
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :rememberable, :trackable
private
def slug_candidates
[
SecureRandom.hex(4).to_s + "-" + self.email[/[^@]+/]
]
end
end
UPDATE 4
For full HTML Markup – see
This is the form that is being produced.
layouts/devise.html.haml
!!! 5
%html
%head
%meta{:charset => "utf-8"}
%title= title
= csrf_meta_tags
%script{:src => "https://use.fontawesome.com/89c3729707.js"}
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1.0"}
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"}
%meta{:name => "description", :content => "#{meta_description}"}
/ Le HTML5 shim, for IE6-8 support of HTML elements
/[if lt IE 9]
%script{:src => "http://html5shim.googlecode.com/svn/trunk/html5.js", :type => "text/javascript"}
/ Le styles
= stylesheet_link_tag "application", :media => "all", :"data-turbolinks" => false
= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js"
= javascript_include_tag "application", :"data-turbolinks" => false
/ Le fav and touch icons
= favicon_link_tag
= render 'layouts/tracking/google_analytics'
%body.home
%div.home_overlay
/= cookie_law!
= render "layouts/navs/navigation_teaser"
= yield
- if params[:action] == "teaser" && !user_signed_in?
= render "layouts/footers/bottom"
UPDATE 6
The issue was my nginx configuration. The one that works is the following:
server {
listen 80;
server_name win-marketing.sciencesupercrew.com www.win-marketing.sciencesupercrew.com;
return 301 https://www.win-marketing.sciencesupercrew.com$request_uri;
}
server {
listen 443 ssl;
server_name win-marketing.sciencesupercrew.com;
passenger_enabled on;
rails_env production;
root /home/demo/windhagermediahub/public;
ssl on;
ssl_certificate /home/demo/ssl/ssl-bundle.crt;
ssl_certificate_key /home/demo/ssl/ssc.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
After adding these lines it started working:
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
4
Answers
The first thing I notice is that you have two
GET
s, instead of aGET
and then aPOST
(as you noticed yourself).But let’s assume the HTML form is correct, since it works in development. That makes me suspect there is some Javascript that is throwing things off. One common problem when moving things from development to production is the Asset Pipeline. So I would open your browser’s console, refresh the page, and see if you get any Javascript errors, especially about files failing to load.
You should also share how you are including Javascript files. Can you share that part of your layout (or whatever)? I would make sure that you use
asset_path
and friends, and not just/assets/application.js
, because the latter will break when you go to production. Even better, usejavascript_include_tag
.I am no expert but since your code is working on local just try the following to get an idea where the problem might be:
a) Run production environment on your local, see if the problem persists there.
b) Try to test run without any javascript enabled or atleast disable custom ones on the production server.
c) Try to redirect after devise authentication to an existing/static page.
I am sure you will get some hints or ideas
This sounds like an SSL issue to me.
Your form is definitely POSTing to the route. You can confirm this by adding
data-remote="true"
to your form HTML in the browser, then watching the console as you make the request:When you POST, however, you are immediately redirected. You can see this if you curl the route:
Here’s where SSL comes in. Rails returns a 301 (moved permanently) error when a request is not SSL but it should be:
I’m not sure how you’ve set up SSL on your server. Are you terminating SSL in a load balancer, for example? Whatever you’re doing, it seems like SSL is the culprit. To confirm temporarily try:
and see if that solves it.
Glad you figured it out! Posting my last comment as an answer below.
Thanks for the live example. So, I click on the submit button and I can see the browser sending a POST request. The server responds successfully, but with a redirect.
POST https://win-marketing.sciencesupercrew.com/en/users/login
->301 Moved Permanently with Location: https://win-marketing.sciencesupercrew.com/en/users/login/
. The form data are sent correctly asuser[email]
anduser[password]
.If you say that this request does not reach Rails, then you need to check your nginx configuration.
UPDATED SOLUTION
The issue was my nginx configuration. The one that works is the following:
After adding these lines it started working: