2016-09-21 76 views
0

導航到我的應用程序主頁面中的鏈接頁面時出現此錯誤。從主頁/主頁導航到另一個頁面時導致Nginx的404錯誤(Rails 5,AWS EC2)

我使用Nginx的和乘客

application/_header.html.erb文件我有這行thelink:

<li><%= link_to 'Comments', comments_path, method: "get" %></li>

爲其在routes.rb我: root to: "application#index" resources :comments

/etc/nginx/sites-available/default

server { 
     listen 80 default_server; 
     listen [::]:80 default_server; 

     root /home/ubuntu/test-aws-deploy-with-git-ec2-rds/public; 

     # Add index.php to the list if you are using PHP 
     index index.html index.htm index.nginx-debian.html; 

     server_name ec2-54-173-78-253.compute-1.amazonaws.com; 

     location/{ 
       proxy_pass http://127.0.0.1:4000; 
       proxy_http_version 1.1; 
       proxy_buffering off; 
       # First attempt to serve request as file, then 
       # as directory, then fall back to displaying a 404. 
       try_files $uri $uri/ =404; 
     } 
} 

不知道爲什麼我不能在這個應用程序之間導航頁面? 我是否需要指定此應用將使用的任何頁面的某處?

回答

1

爲此你需要從下面一行的註釋你的/ etc/nginx的/網站可用/默認

location/{ 
      # First attempt to serve request as file, then 
      # as directory, then fall back to displaying a 404. 
      # try_files $uri $uri/ =404; 
    } 

它的工作,我也面臨着同樣的問題。

+1

非常感謝你!!我一直在這個問題上苦苦掙扎2天... – prasanthrubyist

相關問題