【发布时间】:2017-04-04 20:16:26
【问题描述】:
我创建了一个 Rails API 项目,它可以在本地运行。 (如果我浏览到localhost:3000/api/first,它会在浏览器上打印true。
我已按照此处的步骤 - https://gorails.com/deploy/ubuntu/14.04 并已在我的 EC2 Ubuntu 服务器上部署了 API。
如果我的 IP 地址是 - 1.2.3.4,如果我浏览到 http://1.2.3.4/,我会收到欢迎使用 Nginx 消息。但是,如果我浏览到 http://1.2.3.4/api/first 我会收到 404 错误。
这是我的 /etc/nginx/sites-available/default
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 的文本文件,那么它会显示文件的内容。
【问题讨论】:
标签: ruby-on-rails ubuntu nginx