【发布时间】:2016-11-28 08:06:27
【问题描述】:
在配置 NGINX 以从 nodejs 提供 JSON 时遇到问题。静态文件服务正常,但 /API 请求超时。
NGINX 配置文件
server {
listen 80;
root /home/doctorep/doctoreports;
#index index.html index.htm;
server_name doctoreports.com;
location / {
proxy_pass http://127.0.0.1:8080;
}
location /api/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
}
}
我尝试了使用 google-foo 可以找到的所有配置变体,但都无法正常工作。如果我从 CLI 卷曲 api,我会得到预期的 json 返回。所以我认为问题出在 NGINX 配置中。感谢您提供任何帮助或建议!
【问题讨论】:
-
proxy_pass http:127.0.0.1:8080;有错别字 -
谢谢,更新了问题,服务器上还是同样的问题
-
解决了我的 CouchDB 视图由于依赖冲突而无法工作
标签: json node.js rest nginx command-line-interface