nginx GraphQL服务器连接在生产服务器中被拒绝[已关闭]

5jvtdoz2  于 2023-03-12  发布在  Nginx
关注(0)|答案(1)|浏览(174)

**已关闭。**此问题需要debugging details。当前不接受答案。

编辑问题以包含desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答问题。
昨天关门了。
Improve this question
我有一个Angular/GraphQL/MySQL应用程序,我一直在本地开发,现在我想将它投入生产。
我建立了一个DigitalOcean droplet,注册了一个GoDaddy域名,在服务器上建立了Nginx,创建了一个服务器块,把我的客户端文件夹转移到服务器上。
当我导航到URL时,我看到我的客户端正在运行,但当我想与GraphQL服务器交互时,我得到一个:
开机自检http://localhost:9000/graphql网络::错误连接被拒绝
在我的服务器上,我确实运行了Express服务器,如果我再次运行/server/index.js,将显示以下错误:
错误:侦听EADDRINUSE:地址已被用途:::9000
我一直在关注this guide,但是server块中的变化阻止了url为客户端提供服务,所以我认为这是错误的方法。

kmbjn2e3

kmbjn2e31#

这里的问题是我的graphql.module.ts http配置指向了我的localhost,但是我已经通过更新uri解决了这个问题:

export function createApollo(httpLink: HttpLink): ApolloClientOptions<unknown> {
  const http = httpLink.create({
    uri: 'http://example.com:9000/graphql',
  });

我认为您需要更新nginx配置以包含graphql端点:

location /graphql {
                proxy_pass http://example.com:9000/graphql;
        }

相关问题