【问题标题】:API calls only works with IP Address, not with my Domain (Node.js Express, Godaddy, Google Compute Engine)API 调用仅适用于 IP 地址,不适用于我的域(Node.js Express、Godaddy、Google Compute Engine)
【发布时间】:2018-12-02 21:05:31
【问题描述】:

我有一个在谷歌云计算引擎上运行的节点服务器。 我在计算引擎上使用 ubuntu 作为我的操作系统。

我将防火墙规则添加为 0.0.0.0/0 tcp:4000 我的外部 IP 是 35.196.xxx.xxx。 我的节点服务器在端口 4000 上运行,所以我将 35.196.xxx.xxx:4000 映射到我的 godaddy 域

我在我的服务器上编写了一些 API,我可以使用 post man 和我的 外部IP

能够访问我的网站使用我的域。但我无法使用我的域访问我的 api

即;

http://35.196.xxx.xxx:4000/lyriclines/get-songs-by-person 没关系

http://mydomain。 com/lyriclines/get-songs-by-person 这是不行的

我在使用域时遇到此错误,

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <title>mydomain.com </title>
        <META name="description" content="None">
        <META name="keywords" content="None">

    </head>
    <frameset rows="100%,*" border="0">
        <frame src="http://35.196.xxx.xxx:4000/lyriclines/get-songs-by-person" frameborder="0" />
        <frame frameborder="0" noresize />
    </frameset>
    <!-- pageok -->
    <!-- 08 -->
    <!-- -->

</html>

【问题讨论】:

    标签: node.js ubuntu google-cloud-platform google-compute-engine postman


    【解决方案1】:

    保持端口 80 防火墙规则对 0.0.0.0 开放,并删除 4000 的防火墙规则。然后设置一个 nginx 代理,监听 80 以将 Web 请求路由到您的 Web 服务器端口,并将 api 请求路由到您的 api 端口。 Use this answer 作为参考。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    • 2015-03-03
    • 2020-09-03
    • 2021-07-30
    • 2021-04-20
    • 2015-12-18
    • 2019-07-11
    相关资源
    最近更新 更多