Мое приложение отлично работает в моей среде разработки, но маршруты не работают на моем производственном сервере с nginx и Passenger, где я получаю:
404 Not Found
Однако страница индекса работает как а также CSS и JavaScript.
Я думал, что это связано с проблемами локали или i18n, но изменив маршруты .rb для удаления :locale
, я получил такой же вывод.
Маршруты:
$ rake routes
Prefix Verb URI Pattern Controller#Action
GET /:locale(.:format) welcome#index
services GET /:locale/services(.:format) welcome#services
projects GET /:locale/projects(.:format) welcome#projects
contact GET /:locale/contact(.:format) welcome#contact
GET /:locale(.:format) welcome#index
root GET / welcome#index
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 / site-enable:
server {
listen 80;
listen [::]:80;
root /var/www/test.com/public;
index index.html index.htm index.nginx-debian.html;
server_name test.com www.test.com;
# Turn on Passenger
passenger_enabled on;
passenger_ruby /home/ubuntu/.rbenv/versions/2.5.1/bin/ruby;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
Я использую: - Ruby 2.5.1 - гем 'rails', '~> 5.2.0 '
production.log
показывает отображение страницы приветствия, но не /en/services
, например, при попытке go там:
I, [2020-02-23T17:08:28.146331 #19532] INFO -- : [4cd74925-0637-4b92-92aa-12f693691ecb] Processing by WelcomeController#index as HTML
I, [2020-02-23T17:08:28.146998 #19532] INFO -- : [4cd74925-0637-4b92-92aa-12f693691ecb] Rendering welcome/index.html.erb within layouts/application
I, [2020-02-23T17:08:28.147227 #19532] INFO -- : [4cd74925-0637-4b92-92aa-12f693691ecb] Rendered welcome/index.html.erb within layouts/application (0.1ms)
I, [2020-02-23T17:08:28.148286 #19532] INFO -- : [4cd74925-0637-4b92-92aa-12f693691ecb] Completed 200 OK in 2ms (Views: 1.4ms)
nginx / error.log:
[ N 2020-02-23 17:13:07.1716 25594/T1 age/Wat/WatchdogMain.cpp:1373 ]: Starting Passenger watchdog...
[ N 2020-02-23 17:13:07.1994 25602/T1 age/Cor/CoreMain.cpp:1340 ]: Starting Passenger core...
[ N 2020-02-23 17:13:07.1995 25602/T1 age/Cor/CoreMain.cpp:256 ]: Passenger core running in multi-application mode.
[ N 2020-02-23 17:13:07.2058 25602/T1 age/Cor/CoreMain.cpp:1015 ]: Passenger core online, PID 25602
nginx / access.log:
[23/Feb/2020:17:14:23 +0000] "GET /favicon.ico HTTP/1.1" 200 0 "http://www.XXX.fr/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36"
[23/Feb/2020:17:14:28 +0000] "GET /en/services HTTP/1.1" 404 209 "http://www.XXX.fr/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36"
Как это исправить?