如何在 Google 云平台中打开 Ubuntu 上的端口

How To open ports on Ubuntu in Google cloud platform

我正在尝试 运行 ubuntu 云平台上的 ubuntu apache 服务器,我已经创建了 VM 实例,但我无法连接到任何其他端口,除了80 和 22。 以下是我迄今为止尝试过的所有方法:

唯一似乎开放的端口是 80 和 22。

我还在 VM 设置中同时允许了 HTTP 和 HTTPS 访问

基本上,我要做的是在我的服务器上打开端口。我不确定做错了什么。

您已经安装了 apache,它 运行ning 在端口 80 上,正如您在 nmap 测试中看到的那样,关闭的端口仅表示该端口上没有应用程序 运行ning ,这与过滤不同,请参阅 this for more information, this confirms that your firewall rules are correct (you are allowing traffic from all sources 0.0.0.0/0). By now you should be able to access your website on the port 80, if not I suggest you to follow this GCP guide

所以,如果你想 运行 apache 在端口 443 上,你只需要更改它的配置(基本上你需要为你的服务器获取证书,配置一些相关参数,然后创建一个虚拟主机在 443 端口上侦听,互联网上有很多关于此的指南 google for "enable https apache [your_OS]"),这应该足够了,因为 GCP 上的防火墙规则和您的实例似乎已正确配置。