【发布时间】:2014-11-03 22:57:21
【问题描述】:
我已经开发了一个带有 rails 的 api,在 localhost 中一切正常。 但是当我的 api 在 prod 服务器上时,我的路由出现错误...
这里是场景:
- 我的 prod 服务器配置了 nginx 和 unicorn
- 我在我的路由中使用子域和版本 (api.servername/v1/resource)
routes.rb 文件:
constraints subdomain: 'api' do
scope module: 'api' do
namespace :v1 do
resources :tests, param: :name do
member do
get 'perform'
end
end
resources :jobs
end
end
end
nginx 配置文件:
server {
listen 80;
server_name *.server.com.br;
# Application root, as defined previously
root rails_public_path;
try_files $uri/index.html $uri @app;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://appname;
proxy_connect_timeout 1800;
proxy_read_timeout 1800;
}}
当我在 prod 中运行 rake routes 时,我的路线在那里,但 unicorn 返回 404 页面。
【问题讨论】:
标签: ruby-on-rails-4 nginx unicorn