API调用仅适用于IP地址,不适用于我的域(Node.js Express,Godaddy,Google Compute Engine)

时间:2018-06-23 18:28:22

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

我有一个在Google Cloud Compute Engine上运行的节点服务器。 我在计算机引擎上使用ubuntu作为操作系统。

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

我在服务器上写了一些API,我可以使用post man与我一起访问该api(POST) 外部IP

我可以使用我的域访问我的网站。但是我不能使用我的域访问我的 api

ie;

  

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

     

http://mydomain。 com / lyriclines /按人演唱   不好

使用域时出现此错误,

<!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>

1 个答案:

答案 0 :(得分:1)

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