【发布时间】:2016-11-18 13:48:52
【问题描述】:
我刚刚为 API 使用创建了子域。现在它看起来像 api.example.com 并且一切正常。但是我想禁止从 api.example.com 访问 html 视图。它应该只响应 api 调用。
scope module: 'web' do
root 'home#index'
end
constraints subdomain: 'api' do
scope module: 'api' do
scope module: 'v1' do
end
end
end
我想我可以通过构建适当的位置指令来实现它
server {
listen 80;
listen [::]:80;
rails_env production;
root /home/example/current/public;
server_name api.example.com;
#location ???
}
example.com 域的以下块:
server {
listen 80;
listen [::]:80;
rails_env production;
root /home/example/current/public;
server_name example.com;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
我怎样才能做到这一点?
【问题讨论】:
标签: ruby-on-rails ruby api nginx server