Ruby on rails Rails 6路由在生产中失败,没有日志条目
我部署了我的第一个rails应用程序,我的问题是,在我的production.log中加载状态代码为200的登录页面非常完美Ruby on rails Rails 6路由在生产中失败,没有日志条目,ruby-on-rails,routes,production,Ruby On Rails,Routes,Production,我部署了我的第一个rails应用程序,我的问题是,在我的production.log中加载状态代码为200的登录页面非常完美 I, [2020-05-20T10:47:33.715546 #9931] INFO -- : [cdcf800e-caaf-4ffe-9d88-646e84d91e2a] Started GET "/" for 79.241.182.157 at 2020-05-20 10:47:33 +0200 I, [2020-05-20T10:47:33.716706 #993
I, [2020-05-20T10:47:33.715546 #9931] INFO -- : [cdcf800e-caaf-4ffe-9d88-646e84d91e2a] Started GET "/" for 79.241.182.157 at 2020-05-20 10:47:33 +0200
I, [2020-05-20T10:47:33.716706 #9931] INFO -- : [cdcf800e-caaf-4ffe-9d88-646e84d91e2a] Processing by PagesController#home as HTML
I, [2020-05-20T10:47:33.718426 #9931] INFO -- : [cdcf800e-caaf-4ffe-9d88-646e84d91e2a] Rendering pages/home.html.erb within layouts/application
I, [2020-05-20T10:47:33.719259 #9931] INFO -- : [cdcf800e-caaf-4ffe-9d88-646e84d91e2a] Rendered pages/home.html.erb within layouts/application (Duration: 0.7ms | Allocations: 169)
I, [2020-05-20T10:47:33.723963 #9931] INFO -- : [cdcf800e-caaf-4ffe-9d88-646e84d91e2a] Rendered layouts/_navbar.html.erb (Duration: 0.5ms | Allocations: 164)
I, [2020-05-20T10:47:33.724139 #9931] INFO -- : [cdcf800e-caaf-4ffe-9d88-646e84d91e2a] Rendered layouts/_header.html.erb (Duration: 0.9ms | Allocations: 221)
I, [2020-05-20T10:47:33.724409 #9931] INFO -- : [cdcf800e-caaf-4ffe-9d88-646e84d91e2a] Rendered layouts/_footer.html.erb (Duration: 0.0ms | Allocations: 5)
I, [2020-05-20T10:47:33.724788 #9931] INFO -- : [cdcf800e-caaf-4ffe-9d88-646e84d91e2a] Completed 200 OK in 8ms (Views: 6.7ms | Allocations: 1217)
但如果我路由到另一个页面,我会得到一个404错误,而production.log中没有新条目
My routes.rb:
Rails.application.routes.draw do
resources :emails
root 'pages#home'
get 'unserStall', to: 'pages#our_stall'
get 'galerie', to: 'pages#gallery'
get 'kontakt', to: 'pages#contact'
get 'emails/new', to: 'pages#contact'
get 'notifications', to: 'pages#notifications'
post 'kontakt', to: 'emails#create'
end
我跑了吗
$ RAILS_ENV=production rails routes
我得到这个输出:
Prefix Verb URI Pattern Controller#Action
emails GET /emails(.:format) emails#index
POST /emails(.:format) emails#create
new_email GET /emails/new(.:format) emails#new
edit_email GET /emails/:id/edit(.:format) emails#edit
email GET /emails/:id(.:format) emails#show
PATCH /emails/:id(.:format) emails#update
PUT /emails/:id(.:format) emails#update
DELETE /emails/:id(.:format) emails#destroy
root GET / pages#home
unserStall GET /unserStall(.:format) pages#our_stall
galerie GET /galerie(.:format) pages#gallery
kontakt GET /kontakt(.:format) pages#contact
emails_new GET /emails/new(.:format) pages#contact
notifications GET /notifications(.:format) pages#notifications
POST /kontakt(.:format) emails#create
rails_postmark_inbound_emails POST /rails/action_mailbox/postmark/inbound_emails(.:format) action_mailbox/ingresses/postmark/inbound_emails#create
rails_relay_inbound_emails POST /rails/action_mailbox/relay/inbound_emails(.:format) action_mailbox/ingresses/relay/inbound_emails#create
rails_sendgrid_inbound_emails POST /rails/action_mailbox/sendgrid/inbound_emails(.:format) action_mailbox/ingresses/sendgrid/inbound_emails#create
rails_mandrill_inbound_health_check GET /rails/action_mailbox/mandrill/inbound_emails(.:format) action_mailbox/ingresses/mandrill/inbound_emails#health_check
rails_mandrill_inbound_emails POST /rails/action_mailbox/mandrill/inbound_emails(.:format) action_mailbox/ingresses/mandrill/inbound_emails#create
rails_mailgun_inbound_emails POST /rails/action_mailbox/mailgun/inbound_emails/mime(.:format) action_mailbox/ingresses/mailgun/inbound_emails#create
rails_conductor_inbound_emails GET /rails/conductor/action_mailbox/inbound_emails(.:format) rails/conductor/action_mailbox/inbound_emails#index
POST /rails/conductor/action_mailbox/inbound_emails(.:format) rails/conductor/action_mailbox/inbound_emails#create
new_rails_conductor_inbound_email GET /rails/conductor/action_mailbox/inbound_emails/new(.:format) rails/conductor/action_mailbox/inbound_emails#new
edit_rails_conductor_inbound_email GET /rails/conductor/action_mailbox/inbound_emails/:id/edit(.:format) rails/conductor/action_mailbox/inbound_emails#edit
rails_conductor_inbound_email GET /rails/conductor/action_mailbox/inbound_emails/:id(.:format) rails/conductor/action_mailbox/inbound_emails#show
PATCH /rails/conductor/action_mailbox/inbound_emails/:id(.:format) rails/conductor/action_mailbox/inbound_emails#update
PUT /rails/conductor/action_mailbox/inbound_emails/:id(.:format) rails/conductor/action_mailbox/inbound_emails#update
DELETE /rails/conductor/action_mailbox/inbound_emails/:id(.:format) rails/conductor/action_mailbox/inbound_emails#destroy
rails_conductor_inbound_email_reroute POST /rails/conductor/action_mailbox/:inbound_email_id/reroute(.:format) rails/conductor/action_mailbox/reroutes#create
rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show
update_rails_disk_service PUT /rails/active_storage/disk/:encoded_token(.:format) active_storage/disk#update
rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create
在我的本地机器上,处于开发模式,一切正常。我能做些什么来解决我的问题
我忘记了我的nginx设置,以下是我的可用站点/文件:
# nginx.conf {appName} == actual name
server {
listen 443 default_server;
listen [::]:443 default_server;
root /var/www/{appName}/public;
passenger_enabled on;
passenger_app_env production;
server_name site-preprod.{appName}.de www.site-preprod.{appName}.de;
location / {
try_files $uri $uri/ =404;
}
ssl on;
ssl_certificate /etc/letsencrypt/live/{appName}/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/{appName}/privkey.pem; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/{appName}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{appName}/privkey.pem;
}
server {
if ($host = www.site-preprod.{appName}.de) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = site-preprod.{appName}.de) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 0.0.0.0:80;
server_name site-preprod.{appName}.de www.site-preprod.{appName}.de;
rewrite ^ https://$host$request_uri? permanent
}
您使用的是哪台web服务器?Nginx和passengerIt可能的rails根本没有收到请求。你的NGginx服务器可能有问题。嗯,我也考虑过,因为404页面是由nginx而不是rails加载的。这可能是因为缺少“/”你使用的是哪台web服务器?nginx,passengerIt可能的rails根本没有收到请求。你的NGginx服务器可能有问题。嗯,我也考虑过,因为404页面是由nginx而不是rails加载的。这可能是由于缺少“/”造成的