【发布时间】:2015-03-18 21:19:26
【问题描述】:
我有一个 nginx 配置,无论用户访问哪个 URL,它都能正确地提供 index.html。例如,如果用户访问:myapp.example.com/foo/bar,nginx 正确地服务 index.html,以便 ember.js 可以处理 /foo/bar 路由。
但我还需要 nginx 将 /api 开头的 url 移交给我的 rails 应用程序。这是我当前的配置:
server {
listen 80;
server_name myapp.example.com;
root /home/app/myapp/current/public;
passenger_enabled on;
passenger_user app;
passenger_ruby /usr/bin/ruby2.2;
location /api/ {
}
location / {
try_files $uri $uri/ /index.html?/$request_uri;
}
}
当 ember.js 发出任何 API 请求时,服务器(nginx,而不是 rails)返回 404。我应该在 location /api/ 部分中添加什么,或者我还应该更改什么?
【问题讨论】: