【问题标题】:nginx config for nodejs api not returning /api callsnodejs api的nginx配置不返回/api调用
【发布时间】: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


【解决方案1】:

很抱歉回答我自己的问题...发现 CouchDB 存在依赖冲突并且没有正确地提供视图。通过设置 SSH 隧道并使用 /_utils 尝试修改和查看我的数据库的 /views 来解决这个问题。

【讨论】:

    猜你喜欢
    • 2020-10-19
    • 1970-01-01
    • 1970-01-01
    • 2015-03-21
    • 2020-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-01
    相关资源
    最近更新 更多