Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 带有子域的葡萄api在我的nginx服务器上不工作_Ruby On Rails_Nginx_Passenger_Server_Grape - Fatal编程技术网

Ruby on rails 带有子域的葡萄api在我的nginx服务器上不工作

Ruby on rails 带有子域的葡萄api在我的nginx服务器上不工作,ruby-on-rails,nginx,passenger,server,grape,Ruby On Rails,Nginx,Passenger,Server,Grape,我的主应用程序有myapp.com,api有api.myapp.com。在提供服务的本地开发中,一切都很好,但是当我尝试在我的nginx服务器上测试时,api.myapp.com/v1/products/1给了我一个404。(api.myapp.com重定向到myapp.com,这是由于DNS设置而需要的) 我使用的是,passenger+nginx、rails和grape api,以下是我的设置: routes.rb constraints subdomain: 'api' do moun

我的主应用程序有
myapp.com
,api有
api.myapp.com
。在提供服务的本地开发中,一切都很好,但是当我尝试在我的nginx服务器上测试时,
api.myapp.com/v1/products/1
给了我一个404。(
api.myapp.com
重定向到
myapp.com
,这是由于DNS设置而需要的)

我使用的是,passenger+nginx、rails和grape api,以下是我的设置:

routes.rb

constraints subdomain: 'api' do
  mount API::Base, at: '/'
end
nginx形态

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

        server_name myapp.com www.myapp.com api.myapp.com;
        passenger_enabled on;
        rails_env production;
        root /path/to/myapp.com;


        error_page 500 502 503 504 /50x.html;

        location /50x.html {
                root html;
        }
}
我有CNAME*.myapp指向myapp.com

我可能忽略了一些基本的东西,有人能给我指出正确的方向吗。非常感谢。

添加2个服务器块

server {
  listen  80 default_server;
  server_name app.com;
  ...
}

server {
  listen  80;
  server_name subdomain.app.com;
  ...
}