[英]Rails API Routing issue (only in production with nginx + unicorn)
i've developed an api with rails, and in localhost everything was ok. 我已经开发了带有Rails的api,在localhost中,一切正常。 but when my api is at prod server, i got errors with my routes...
但是当我的api在生产服务器上时,我的路线出错了...
here is the scenario: 这是场景:
routes.rb file: route.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 conf file: nginx conf文件:
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;
}}
when i run rake routes
in prod, my routes are there, but unicorn returns the 404 page. 当我在生产中运行
rake routes
时,我的路线在那里,但是独角兽会返回404页面。
It seems like a TLD problem. 好像是TLD问题。 It's not only on Unicorn.
不仅在独角兽上。 If you config your /etc/hosts with the same domain, you will get the same error.
如果将/ etc / hosts配置为相同的域,则会得到相同的错误。
Removing the constraint of subdomain in the routes.rb works as expected. 删除route.rb中的子域约束,按预期进行。
routes.rb file: route.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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.