2017-04-04 74 views
1

我創建了一個Rails API項目,它在本地工作。 (如果我瀏覽到localhost:3000/api/first它打印true瀏覽器Rails API 404錯誤 - 使用Capistrano,Nginx和Passenger部署

我已經在這裏遵循的步驟 - https://gorails.com/deploy/ubuntu/14.04,並已部署的API對我的EC2 Ubuntu服務器

如果我的IP地址 - 1.2.3.4,如果我瀏覽到http://1.2.3.4/我得到的歡迎Nginx的消息。但是,如果我瀏覽到http://1.2.3.4/api/first我得到一個404錯誤。

這裏是我的的/ etc/nginx的/網站可用/默認

server { 
    listen 80; 
    listen [::]:80 ipv6only=on; 

    server_name ""; 
    passenger_enabled on; 
    rails_env production; 
    root   /home/ubuntu/rails/current/public; 

    # redirect server error pages to the static page /50x.html 
    error_page 500 502 503 504 /50x.html; 
    location = /50x.html { 
     root html; 
    } 
} 

如果我創建一個名爲api的文件夾(在/home/ubuntu/rails/current/public中),並在其中創建一個名爲first的文本文件,那麼它會顯示文件的內容。

回答

0

安裝ngnix乘客模塊並添加路徑到ngnix conf文件。

代碼應該不會停,如:

server { 
    listen 80; 
    server_name ""; 

    # Tell Nginx and Passenger where your app's 'public' directory is 
    root /var/www/app_name/public; 

    # Turn on Passenger 
    passenger_enabled on; 
    passenger_ruby /root/.rvm/gems/ruby-2.2.2/wrappers/ruby; 
} 
相關問題