我正面临一个让我抓狂的问题--主要是因为没有日志或错误消息,而且它在本地主机上工作,而不是在生产上工作。
问题:
我去登录页面-输入凭证(100%正确)并点击登录按钮。没有登录,没有消息,没有日志条目,没有登录。它在本地主机上正常工作。
没有什么我可以给你,尽管我正在工作的配置-我希望其他人面对这个问题,并能够解决它。
Ubuntu版本:
发行商ID: Ubuntu描述:Ubuntu14.04.3 LTS发行版: 14.04代码名: trusty
Rails版本:
Rails 5.0.1
Ruby版本:
Ruby2.4.0p0 (2016-12-24修订版57164) x86_64-linux
设计版本:
设计(4.2.0)
Nginx版本:
nginx版本: nginx/1.10.2
乘客版:
乘客5.1.2
生产日志:
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:17Nginx日志(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: 更新:
在以清除代替设计之后,这个问题仍然存在。根据日志,它试图发出一个GET请求,而它应该是POST。该表单在localhost上工作,一切看起来都是正确的。我甚至在登录表单中指定了方法,但它仍然在发出GET。我在这里啃灰尘。
UPDATE2:
我完全删除了Devise和代码中对它的任何引用,然后再次设置它--没有修改或定制来设计。正在使用标准视图和表单。
SignIn表单(会话新建)
<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" %>更新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输出: RAILS_ENV=production包exec
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格式化的表格版本
<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更新4
有关完整的HTML标记,请参见
这就是正在产生的形式。
布局/设计.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"更新6
问题是我的nginx配置。有效的办法如下:
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;
}添加这些行之后,它就开始工作了:
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;发布于 2017-02-24 06:20:09
很高兴你搞清楚了!下面是我最后一条评论的回复。
谢谢这个活生生的例子。所以,我点击submit按钮,就可以看到浏览器发送一个POST请求。服务器成功响应,但使用重定向。POST https://win-marketing.sciencesupercrew.com/en/users/login -> 301 Moved Permanently with Location: https://win-marketing.sciencesupercrew.com/en/users/login/.表单数据以user[email]和user[password]的形式正确发送。
如果您说这个请求没有到达Rails,那么您需要检查nginx配置。
更新解决方案
问题是我的nginx配置。有效的办法如下:
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;
}添加这些行之后,它就开始工作了:
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;发布于 2017-02-23 15:13:38
对我来说,这听起来像是个SSL问题。
您的表单绝对是路由的POSTing。您可以通过在浏览器中将data-remote="true"添加到表单HTML中来确认这一点,然后在发出请求时监视控制台:
XHR finished loading: POST "https://win-marketing.sciencesupercrew.com/en/users/login"然而,当你发帖时,你会立即被重定向。你可以看到,如果你卷曲路线:
$ curl -i -X POST https://win-marketing.sciencesupercrew.com/en/users/login
HTTP/1.1 301 Moved Permanently
Server: nginx/1.10.2
Date: Thu, 23 Feb 2017 14:58:04 GMT
Content-Type: text/html
Content-Length: 185
Location: https://win-marketing.sciencesupercrew.com/en/users/login/
Connection: keep-alive这是SSL进来的地方。如果请求不是SSL,但应该是:Rails返回一个301 (永久移动)错误:
def force_ssl_redirect(host_or_options = nil)
unless request.ssl?
options = {
:protocol => 'https://',
:host => request.host,
:path => request.fullpath,
:status => :moved_permanently
}我不知道您是如何在服务器上设置SSL的。例如,您是否在负载均衡器中终止SSL?不管你在做什么,看起来SSL才是罪魁祸首。确认暂时尝试:
# config/production.rb
config.force_ssl = false看看能不能解决这个问题。
发布于 2017-02-22 21:06:11
我注意到的第一件事是,您有两个GET,而不是一个GET和一个POST (正如您自己注意到的那样)。
但是让我们假设HTML表单是正确的,因为它在开发中工作。这让我怀疑有一些Javascript正在抛出东西。从开发到生产的一个常见问题是资产管道。因此,我将打开浏览器的控制台,刷新页面,并查看是否有任何Javascript错误,特别是有关文件无法加载的错误。
您还应该分享如何包含Javascript文件。你能分享你的部分布局(或其他什么)吗?我会确保您使用的是asset_path和朋友,而不仅仅是/assets/application.js,因为当您投入生产时,后者就会中断。更好的是,使用javascript_include_tag。
https://stackoverflow.com/questions/42329322
复制相似问题