【发布时间】:2017-12-29 19:14:25
【问题描述】:
我有一个在 Nginx 服务器上运行的 AngularJS 应用程序。我正在尝试将请求代理到在 Puma 中运行的 Rails API。
我想要对 api 的所有请求,例如:http://127.0.0.1/api/getTranslationLanguages go to API server (Puma) 在 unix 套接字中侦听。
还有我的 Nginx 配置:
upstream api.development {
# Path to Puma SOCK file, as defined previously
server unix:/tmp/puma.sock fail_timeout=0;
}
server {
listen 80;
server_name localhost;
access_log logs/host.access.log;
rewrite_log on;
location / {
root /path-to-app;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
location /api {
proxy_pass http://api.development;
}
...
}
目前我在请求中收到 404 错误。 错误日志:
Request URL:http://127.0.0.1/api/getTranslationLanguages
Request Method:GET
Status Code:404 Not Found
Remote Address:127.0.0.1:80
Referrer Policy:no-referrer-when-downgrade
【问题讨论】: